MySQL Table Results to Process Another Table Results
Below you will find my code, it's not it all in it's entirety, but shows what's important. I have some custom functions that are being used just to note out. What I have my code doing is searching a MySQL table and displaying all of the results based on the current session user id. Then I loop through those results and for each one I search another table. This works perfectly, but I just want to see if there is a better way to do this without having to loop and search a table for every result row.
Code: http://pastie.org/5191376
Re: MySQL Table Results to Process Another Table Results
It works, but using nested SQL statements would be more efficient (less resources on the server and faster results).
PHP Code:
SELECT * FROM qpons WHERE id = (SELECT qpon_id FROM participation WHERE shop_id = '{$session->user_id}')
Re: MySQL Table Results to Process Another Table Results
That didn't seem to work :(
I got the following error:
Database query failed: Illegal mix of collations (utf8_unicode_ci,IMPLICIT) and (utf8_general_ci,IMPLICIT) for operation '='
Re: MySQL Table Results to Process Another Table Results
You have one database field set to utf8_unicode_ci and the other to utf8_general_ci. Either fix the collations, or set the collation in the SQL query.
http://dev.mysql.com/doc/refman/5.0/...t-collate.html
Re: MySQL Table Results to Process Another Table Results
Hallelujah! I had made the participation table all in utf8_general_ci. Switched it and now it works baby! :)