51 users online (1 members and 50 guests)  


  Results 1 to 3 of 3

Related

  1. sql syntax error    Forum: PHP Forum
    Replies: 1
  2. Select Case SQL Statement...    Forum: Databases
    Replies: 7
  3. MySQL Select statement    Forum: Databases
    Replies: 1
  4. XML syntax question~    Forum: Website Scripts Forum
    Replies: 4
  1. #1
    newphpcoder's Avatar
    Junior Member

    Status
    Offline
    Join Date
    Sep 2010
    Posts
    52

    Syntax for Select Statement

    Good day!


    I want to know if what is the correct sysntax for Selecting multiple data in one column.


    I have a table trace and i have column name and id
    my list name are: name1, name1total, name2,name2total,name3,name4, and name5, but i wamnt to select only is the name 1,name3,name4, and name5
    I have a table trans and it has id.

    I try this code:

    Code:
    SELECT t.name FROM trace t, trans c WHERE t.name = 'name1' || 'name 3' || 'name4' || 'name5' AND t.id=c.id;
    In that code all the name was selected eventhough I did not select the name1total,name2,name2total.

    Thank you

  2. #2
    paullopez's Avatar
    New User

    Status
    Offline
    Join Date
    Feb 2012
    Posts
    14

    Re: Syntax for Select Statement

    You should try following code:

    Select t.name FROM trace t, trans c WHERE
    t.name IN( 'name1','name 3', 'name4','name5') AND
    t.id = c.id;

  3. #3
    slash678's Avatar
    New User

    Status
    Offline
    Join Date
    Jul 2012
    Posts
    1

    Re: Syntax for Select Statement

    Quote Originally Posted by newphpcoder View Post
    Good day!


    I want to know if what is the correct sysntax for Selecting multiple data in one column.


    I have a table trace and i have column name and id
    my list name are: name1, name1total, name2,name2total,name3,name4, and name5, but i wamnt to select only is the name 1,name3,name4, and name5
    I have a table trans and it has id.

    I try this code:

    Code:
    SELECT t.name FROM trace t, trans c WHERE t.name = 'name1' || 'name 3' || 'name4' || 'name5' AND t.id=c.id;
    In that code all the name was selected eventhough I did not select the name1total,name2,name2total.

    Thank you
    ]]


    Select * From Table Name

    Polybutylene