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

  • Home
  • SEARCH
  • 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 8525451
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T07:58:53+00:00 2026-06-11T07:58:53+00:00

This works fine, but there is a problem when it returns less than 8

  • 0

This works fine, but there is a problem when it returns less than 8 results.
Is there any alternative than to repeat a query for the rest of the results that are missing?
Any help would be appreciated, thanks.

       $vacation = mysql_query("SELECT i.* 
       FROM vacation_offer_tbl i
       INNER JOIN vacation_offer_pics_tbl c ON (c.vacat_offer_id = i.vacat_offer_id)
       WHERE i.conditional ='1' 
       AND c.pic_1 != ''
       // if < 8 results rerurn the rest where c.pic_1 ='nothing' 
       ORDER BY rand() 
       LIMIT 8") or die(mysql_error());
  • 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-06-11T07:58:54+00:00Added an answer on June 11, 2026 at 7:58 am

    Im not sure how well this will work with the ORDER BY rand() but something like this might help

    SELECT i.*, if(c.pic_1 != '',0,1) as sortOn
    FROM vacation_offer_tbl i
    INNER JOIN vacation_offer_pics_tbl c ON (c.vacat_offer_id = i.vacat_offer_id)
    WHERE i.conditional ='1' 
    ORDER BY sortOn, rand() 
    LIMIT 8
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using this function: preg_match_all('/((\d{9})\.html)/s', $content, $results); It works fine but i just want
This code works fine, but I'll want to handle exception if any thing goes
I currently have this and it works fine but I wanted to have a
This works perfectly fine on localhost but doesn't work on my server, could anyone
This works fine: TreeMap <String, ArrayList> x_probs_org = new TreeMap<String, ArrayList>(); But this: TreeMap
This script works fine on single click but on double click it shows both
This loop works fine in Main function but when copy this loop code in
This sql command works fine in sqlitemanager but in my android application this don't
This function works fine if I disable errors. But I have to solve them.
I have an app that works fine in iOS 4, but there is a

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.