Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 New to SQL and need some help

Author  Topic 

ccdavies
Starting Member

11 Posts

Posted - 2012-01-23 : 05:28:05
Hi.

I am trying to display just the entries which have a value of 500 or less in 'field_id_8'.

When I test this code it returns all of the entries, not entries with a value of 500 or less.


SELECT titles.entry_id, titles.title, data.field_id_18, data.field_id_10 AS tour_excerpt, data.field_id_8 AS tour_price, titles.url_title, assets_entries.asset_id, SUBSTR( assets.file_path, 12 ) as file_path
FROM exp_channel_titles AS titles
LEFT JOIN exp_channel_data AS data ON data.entry_id = titles.entry_id
LEFT JOIN exp_assets_entries AS assets_entries ON assets_entries.entry_id = data.entry_id
LEFT JOIN exp_assets AS assets ON assets_entries.asset_id = assets.asset_id
WHERE titles.channel_id = '4'
AND assets_entries.field_id = '84'
AND data.field_id_8 <= '500'
GROUP BY titles.entry_id


Can anyone see anything wrong with my code?

Thank you!

rajan.nithin
Starting Member

42 Posts

Posted - 2012-01-23 : 05:42:34
Please confirm whether the columns titles.channel_id,assets_entries.field_id,data.field_id_8 have been set to numeric datatypes such as int, bigint, float etc. If yes remove the single quotes. try it as quoted below:



quote:
SELECT titles.entry_id, titles.title, data.field_id_18, data.field_id_10 AS tour_excerpt, data.field_id_8 AS tour_price, titles.url_title, assets_entries.asset_id, SUBSTR( assets.file_path, 12 ) as file_path
FROM exp_channel_titles AS titles
LEFT JOIN exp_channel_data AS data ON data.entry_id = titles.entry_id
LEFT JOIN exp_assets_entries AS assets_entries ON assets_entries.entry_id = data.entry_id
LEFT JOIN exp_assets AS assets ON assets_entries.asset_id = assets.asset_id
WHERE titles.channel_id = 4
AND assets_entries.field_id = 84
AND data.field_id_8 <= 500
GROUP BY titles.entry_id
Go to Top of Page

ccdavies
Starting Member

11 Posts

Posted - 2012-01-24 : 09:26:01
Thank you!!!
Go to Top of Page
   

- Advertisement -