What do you mean assemble the SQL in Code. I am using MYSQL 4.1 and PHP.
Daniel Kasak wrote: > > altendew wrote: > >> Im trying to create one query here. I know why its failing because CASE >> can >> not be used like this, but how could I ever do a query like this. >> >> [CODE] >> SELECT b.* >> FROM bonus b >> JOIN >> CASE b.type >> WHEN 'custom' THEN 'bonusCustom g' >> WHEN 'pts' THEN 'bonusPts g' >> WHEN 'ptc' THEN 'bonusPtc g' >> END >> ON g.bid=b.id >> WHERE (b.hits IS NULL || b.hits>0) >> ORDER BY RAND() >> [/CODE] >> >> Anyway this is possible! >> > > Why not assemble the SQL in code and *then* send it to MySQL? > Otherwise, a very dodgy 'solution' would be to left-join all the tables, > and then put the case statement in the select statement. > > -- > Daniel Kasak > IT Developer > NUS Consulting Group > Level 5, 77 Pacific Highway > North Sydney, NSW, Australia 2060 > T: (+61) 2 9922-7676 / F: (+61) 2 9922 7989 > email: [EMAIL PROTECTED] > website: http://www.nusconsulting.com.au > > -- > MySQL General Mailing List > For list archives: http://lists.mysql.com/mysql > To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED] > > > -- View this message in context: http://www.nabble.com/Selecting-Different-Tables-Based-on-Value.-Case-seems-to-fail.-tf2943218.html#a8230152 Sent from the MySQL - General mailing list archive at Nabble.com. -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]