halfFAST
2008-10-23 23:53:16 UTC
Currently, I am thinking I might have to query for the 'Y' values and add a new column with the value of 1 for these, then do all the 'N' values and select 0 as my new column's value and then merge those two result sets. Something like this:
SELECT newsID, title, url, description, body, 1 as isActive
FROM tbl_news_data
WHERE active = 'Y'
UNION
SELECT newsID, title, url, description, body, 0 as isActive
FROM tbl_news_data
WHERE active = 'N'
with `isActive` being my new column with the numeric value of 1 or 0 and leaving the old 'Y'/'N' values(column `active`) out of the result set.
Barring no syntax errors in my post, is this going to be an efficient way to do this? Are there better/simpler ways to do it with a query and not in my code? I just need the query result to be in a specific format and I can't change the table as other people's code expects the 'Y'/'N' values(and no, I can't ask them to change what they are looking for - I'm stuck with using the data as is).