#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2013
    Posts
    2
    Rep Power
    0

    Where Statements


    Hi There

    I have a table of trips in a schedule, The trip will consist of an outward and a return.

    both records will look like this

    ScheduleID|Time|TripId|PuAddress|DoAddress

    I would like to be able to select schedule items where EITHER The PuAddress OR DoAddress matches my search

    The only way i can think to do it is by using a union to to grab both side of the trip

    SELECT * FROM trips where PUaddress = "address"
    UNION
    SELECT * FROM trips where DOaddress = "address"


    My gut feeling is there has to be an easier way??

    Ian
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Regular (2000 - 2499 posts)

    Join Date
    Jan 2003
    Location
    Paris Uppland
    Posts
    2,370
    Rep Power
    391
    Code:
    select *
      from trips 
     where 'address' in (PuAddress,DoAddress)
    You should use single quotes for strings in SQL.

IMN logo majestic logo threadwatch logo seochat tools logo