www.webdeveloper.com
Results 1 to 4 of 4

Thread: [RESOLVED] SQL Query HELP needed

  1. #1
    Join Date
    Jan 2011
    Posts
    42

    resolved [RESOLVED] SQL Query HELP needed

    I have the following table layout
    ID,Vendor,Switch,Postion,Emailaddress,YESorNO
    1 lucent test MC s@ddd.com Y
    2 lucent test ST s1@dd.com
    3 lucent test1 DR s2@dd.com

    What i want to do is if YESorNO = Y and Vendor = lucent i need the emailaddress to all switches that are the same as the ID 1

    So after my query i need the following
    Switch,Emailaddress
    test s@dd.com
    test s1@dd.com

    here is the code that i got so far but if only gives me information for ID 1
    PHP Code:
    SELECT FROM `MailingListWHERE `Vendor`='lucent' AND `yesorno` = 'Y' 

  2. #2
    Join Date
    Dec 2002
    Location
    St. Louis, MO, USA
    Posts
    1,582
    SELECT * FROM `MailingList` WHERE `Switch` = (SELECT `Switch` FROM `MailingList` WHERE `Vendor`='Lucent' AND `YESorNO` = 'Y')

  3. #3
    Join Date
    Jan 2011
    Posts
    42
    When i do the following command
    PHP Code:
    SELECT FROM `MailingListWHERE `Switch` = (SELECT `SwitchFROM `MailingListWHERE `Vendor`='Lucent' AND `YESorNOBWM` = 'Y'
    I get the following error
    #1242 - Subquery returns more than 1 row

  4. #4
    Join Date
    Dec 2002
    Location
    St. Louis, MO, USA
    Posts
    1,582
    SELECT * FROM `MailingList` WHERE `Switch` IN (SELECT `Switch` FROM `MailingList` WHERE `Vendor`='Lucent' AND `YESorNO` = 'Y')

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles