SitePoint Sponsor

User Tag List

Results 1 to 2 of 2

Hybrid View

  1. #1
    SitePoint Guru
    Join Date
    Sep 2008
    Posts
    977
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    trying to get a result if another isn't returned.

    Hi,

    I am querying a table for a specific range of rows. If the query returns nothing, I want another range of rows to be selected. Either it returns >0 specific rows or it is to return a (default) specific 6.

    Should I do this in my server side language or can I do it all in the query? I am wondering about case where...but wouldn't it check for a zero return for each row rather than for the whole query?

    bazz

  2. #2
    SitePoint Guru
    Join Date
    Sep 2008
    Posts
    977
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Just to clarify...

    here is the current query

    Code MySQL:
    select 
                                    bt.condition_name
                                  , bt.condition_details 
                                  from booking_terms as bt
                                   where business_id = ?

    if there is nothing returned at all by the query, I need to output the default values. if just one record is returned, I need no more to be done.

    bazz


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •