not-exists

Working NOT EXISTS sql query

  1. #this query now works. It shows me all vehicles which are available on a particular day
  2.  
  3. SELECT node.nid AS nid,
  4. node.title AS title
  5. FROM node
  6. WHERE (node.STATUS <> 0)

EXISTS vs NOT EXISTS as a sql query

  1. # I have 3 vehicle nodes: 3, 26, 28. The following query should return ONLY nid 3, but it returns 3, 26, 28.
  2.  
  3. SELECT node.nid AS nid
  4. FROM node

Showing vehicle nodes which don't exist in vehicle_booking nodes

  1. #this SQL query has 2 parts. Part 1 shows all vehicles and vehicle bookings nodes (both are CCK types). This returns 4 rows (3 vehicles + 1 vehicle booking)
  2.  
  3. SELECT node.nid AS nid,
Syndicate content