Thread: Some problems

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

    Join Date
    Jun 2013
    Posts
    1
    Rep Power
    0

    Some problems


    select naam, telefoonummer
    from klant, boeking
    where boekdatum = '2005-3-23'
    or boekdatum = '2005-3-24

    it wont work it will just enlist all the people i put in there

    the same problem with this one

    SELECT naam, telefoonummer, `aantal dagen`
    FROM klant, boeking, reis
    WHERE boekdatum = '2005-3-23'
    OR boekdatum = '2005-3-24'
    AND `aantal dagen` >= '14'


    anyone who knows what i did wrong, pls tell me how to fix it
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Regular (2000 - 2499 posts)

    Join Date
    Mar 2006
    Posts
    2,436
    Rep Power
    1688
    You are, I presume, linking data from two or three tables which you are doing by the old implicit join sytnax which is not good. Provide SHOW CREATE TABLE output for each table and mention how they are linked to one another.
    The moon on the one hand, the dawn on the other:
    The moon is my sister, the dawn is my brother.
    The moon on my left and the dawn on my right.
    My brother, good morning: my sister, good night.
    -- Hilaire Belloc
  4. #3
  5. SQL Consultant
    Devshed Supreme Being (6500+ posts)

    Join Date
    Feb 2003
    Location
    Toronto Canada
    Posts
    27,118
    Rep Power
    4274
    Originally Posted by derp619
    WHERE boekdatum = '2005-3-23'
    OR boekdatum = '2005-3-24'
    AND `aantal dagen` >= '14'
    besides the problem in not joining the tables properly -- which is the most important problem -- you also need to fix these ANDs and ORs

    replace the above with either this --
    Code:
    WHERE ( boekdatum =  '2005-3-23'
         OR boekdatum =  '2005-3-24' )
      AND aantal dagen >= 14
    or this --
    Code:
    WHERE boekdatum IN ( '2005-3-23' , '2005-3-24' )
      AND aantal dagen >= 14
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
  6. #4
  7. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2013
    Posts
    7
    Rep Power
    0
    i think u need to make a join between those two tables

    for eg:

    select * from t1 inner join t2 on t1.id=t2.foreign_t1_id

    ___________________________________________________
    Free Online Generator (MD5,SHA,AES,Ciphers...)
    http : // www. generaz.com

IMN logo majestic logo threadwatch logo seochat tools logo