SELECT gigs.gig_ID, gigs.gig_date, gigs.gig_info, gigs.gig_status, gigs.gig_times, gigs.gig_band_id, gigs.gig_venue_id, gigs.gig_band, gigs.gig_venue, gigs.gig_adminID, (band_cats.cat_singular) AS band_cat, (venue_cats.cat_singular) AS venue_cat, (band.password_style) AS style, (venue.password_style) AS address, gig_address, gig_musicStyle, (band.password_fullTitle) AS band, (venue.password_fullTitle) AS venue FROM gigs INNER JOIN passwords AS band ON band.password_ID = gigs.gig_band_id INNER JOIN passwords AS venue ON venue.password_ID = gigs.gig_venue_id INNER JOIN categories AS band_cats ON band.password_status = band_cats.cat_id INNER JOIN categories AS venue_cats ON venue.password_status = venue_cats.cat_id WHERE gig_status <= 3 AND gig_status > 0 ORDER BY gig_date, gig_times, RAND(SECOND(gig_entryDate)) ASC LIMIT 400, 40