-
November 5th, 2012, 02:32 PM
#1
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
-
November 5th, 2012, 04:05 PM
#2
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}')
If the post was helpful...Rate it! Remember to use [code] or [php] tags.
-
November 5th, 2012, 07:05 PM
#3
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 '='
-
November 5th, 2012, 07:50 PM
#4
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
If the post was helpful...Rate it! Remember to use [code] or [php] tags.
-
November 5th, 2012, 07:57 PM
#5
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!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|