I am in the process of converting my site from using MS Access to MySQL. (pats self on back :)
However I'm running into some issues with some of my queries that I'm hoping to convert to work with MySQL.
My database structure is explained here:
http://www.experts-exchange.com/Microsoft/Development/MS_Access/Access_Architecture-Design/Q_22569151.htmlFrom the above question I got a query to work which was grouping and returning fields including a MEMO field. To get more than the 255 characters of the MEMO field I had to use the first() function to exclude the MEMO field in the GROUP by for Access. See the question below:
http://www.experts-exchange.com/Microsoft/Development/MS_Access/Access_Architecture-Design/Q_22569639.htmlNow this query does not work as first() is not a valid function in MySQL, I don't know if there is an equivalent.
here's the query:
SELECT first(answers.answer_text)
as answer_text,
answers.answer_id, answers.q_id, answers.member_id,
members.nick, members.total_votes, members.weemee,
SUM(IIF(IsNull(avotes.vote
), 0, avotes.vote)) as votes
FROM ((answers INNER JOIN members ON answers.member_id = members.member_id)
LEFT JOIN avotes ON answers.answer_id = avotes.a_id)
WHERE answers.q_id = 250
GROUP BY answers.answer_id, answers.q_id, answers.member_id,
members.nick, members.total_votes, members.weemee
The error I get when I try and run it in the MySQL Browser:
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '(answers.answer_text) as answer_text, answers.answer_id, answers.q_id, answers.m' at line 1
I also suspect the IIF function is not exactly the same in MySQL
Could the experts here help me work this query, or rewrite it?
Start Free Trial