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]