Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7046255
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T02:37:43+00:00 2026-05-28T02:37:43+00:00

I have a query that pulls values from multiple tables. I want to order

  • 0

I have a query that pulls values from multiple tables. I want to order them by shows_date ASC only I cant seem to get it to ouput any data, Can anybody see a problem with my syntax?

$artists = $wpdb->get_results("SELECT * FROM " . GIGPRESS_ARTISTS . " AS a, " . GIGPRESS_SHOWS . " AS s, ORDER BY s.show_date ");

var_dump($artists);

foreach($artists as $artist_group) 
{
    $shows = $wpdb->get_results("SELECT * 
                                 FROM " . GIGPRESS_ARTISTS . " AS a, " . GIGPRESS_VENUES . " as v, " . GIGPRESS_SHOWS ." AS s 
                                 LEFT JOIN  " . GIGPRESS_TOURS . " AS t 
                                   ON s.show_tour_id = t.tour_id 
                                 WHERE " . $date_condition . " 
                                   AND show_status != 'deleted' AND s.show_artist_id = " . $artist_group->artist_id . " 
                                   AND s.show_artist_id = a.artist_id AND s.show_venue_id = v.venue_id " . $further_where . " 
                                 ORDER BY s.show_date " . $sort . ",s.show_expire " . $sort . ",s.show_time ". $sort . $limit);
}

DUMP RETURNS

array(72) { [0]=> object(stdClass)#260 (25) { [“artist_id”]=> string(1) “1” [“artist_name”]=> string(14) “Damien Dempsey” [“artist_order”]=> string(1) “0” [“show_id”]=> string(1) “1” [“show_artist_id”]=> string(1) “1” [“show_venue_id”]=> string(1) “1” [“show_tour_id”]=> string(1) “0” [“show_date”]=> string(10) “2012-01-29” [“show_multi”]=> string(1) “0” [“show_time”]=> string(8) “20:30:00” [“show_expire”]=> string(10) “2012-01-29” [“show_price”]=> string(7) “£10.00” [“show_tix_url”]=> string(0) “” [“show_tix_phone”]=> string(0) “” [“show_ages”]=> string(8) “All Ages” [“show_notes”]=> string(0) “” [“show_related”]=> string(1) “0” [“show_status”]=> string(7) “deleted” [“show_tour_restore”]=> string(1) “0” [“show_address”]=> NULL [“show_locale”]=> NULL [“show_country”]=> NULL [“show_venue”]=> NULL [“show_venue_url”]=> NULL [“show_venue_phone”]=> NULL } [1]=> object(stdClass)#259 (25) { [“artist_id”]=> string(1) “2” [“artist_name”]=> string(10) “Gary Dunne” [“artist_order”]=> string(1) “0” [“show_id”]=> string(1) “1” [“show_artist_id”]=> string(1) “1” [“show_venue_id”]=> string(1) “1” [“show_tour_id”]=> string(1) “0” [“show_date”]=> string(10) “2012-01-29” [“show_multi”]=> string(1) “0” [“show_time”]=> string(8) “20:30:00” [“show_expire”]=> string(10) “2012-01-29” [“show_price”]=> string(7) “£10.00” [“show_tix_url”]=> string(0) “” [“show_tix_phone”]=> string(0) “” [“show_ages”]=> string(8) “All Ages” [“show_notes”]=> string(0) “” [“show_related”]=> string(1) “0” [“show_status”]=> string(7) “deleted” [“show_tour_restore”]=> string(1) “0” [“show_address”]=> NULL [“show_locale”]=> NULL [“show_country”]=> NULL [“show_venue”]=> NULL [“show_venue_url”]=> NULL [“show_venue_phone”]=> NULL } [2]=> object(stdClass)#261 (25) { [“artist_id”]=> string(1) “3” [“artist_name”]=> string(19) “London Irish Centre” [“artist_order”]=> string(1) “0” [“show_id”]=> string(1) “1” [“show_artist_id”]=> string(1) “1” [“show_venue_id”]=> string(1) “1” [“show_tour_id”]=> string(1) “0” [“show_date”]=> string(10) “2012-01-29” [“show_multi”]=> string(1) “0” [“show_time”]=> string(8) “20:30:00” [“show_expire”]=> string(10) “2012-01-29” [“show_price”]=> string(7) “£10.00” [“show_tix_url”]=> string(0) “” [“show_tix_phone”]=> string(0) “” [“show_ages”]=> string(8) “All Ages”


Ive tried the following

foreach($artists as $artist_group) {
        $shows = $wpdb->get_results("SELECT * FROM " . GIGPRESS_ARTISTS . " AS a, " . GIGPRESS_VENUES . " as v, " . GIGPRESS_SHOWS ." AS s LEFT JOIN  " . GIGPRESS_TOURS . " AS t ON s.show_tour_id = t.tour_id WHERE " . $date_condition . " AND show_status != 'deleted' ORDER BY s.show_date ASC " . $limit);

Which works in regards to the ordering, but it outputs each value about 100 times or something stupid..

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T02:37:43+00:00Added an answer on May 28, 2026 at 2:37 am

    the comma after AS s, is extraneous

    SELECT * FROM ” . GIGPRESS_ARTISTS . ” AS a, ” . GIGPRESS_SHOWS .
    ” AS s, ORDER BY s.show_date

    additionally you seem to be missing a WHERE clause or a JOIN ON statement.

    this query would produce a cross-join with (all gigs) x (all bands) so that in your foreach you will process each band once for every gig in the system, instead of once for each band/show.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a query that pulls up questions from one table and answers from
We have a SQL query that pulls a large number of fields from many
I have a LINQ to ENTITY query that pulls from a table, but I
I am trying to write a SQL query that pulls from 3 tables and
So I have this query that pulls from my links and votes table and
I have a fairly complex SQL query that pulls different types of products from
I have a LINQ query that pulls ID values with integers: var data =
Have a simple page that pulls results from MySQL and displays them in a
I have a page that pulls together aggregate data from two different tables. I
I have a query that pulls back a user's feed which is essentially all

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.