PHP MySQL Table Results to Process Another Table Results
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5

Thread: MySQL Table Results to Process Another Table Results

Hybrid View

  1. #1
    Join Date
    Jul 2012
    Posts
    8

    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

  2. #2
    PeejAvery's Avatar
    PeejAvery is online now Super Moderator Power Poster
    Join Date
    May 2002
    Posts
    10,879

    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.

  3. #3
    Join Date
    Jul 2012
    Posts
    8

    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 '='

  4. #4
    PeejAvery's Avatar
    PeejAvery is online now Super Moderator Power Poster
    Join Date
    May 2002
    Posts
    10,879

    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.

  5. #5
    Join Date
    Jul 2012
    Posts
    8

    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
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center