SitePoint Sponsor

User Tag List

Results 1 to 2 of 2

Hybrid View

  1. #1
    SitePoint Addict
    Join Date
    Feb 2013
    Posts
    243
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Quick question about selecting multiple values in a sql query.

    So i have this:

    Code PHP:
    $query = mysql_query("SELECT * FROM textareas WHERE Section = 'forskola-allmant'") or die(mysql_error());

    And i want to select one more section value, how do i do this? I tried just Seperation them with a comma like this:

    Section = 'forskola-allmant', 'forskola-miljo' but this didnt work, I als tried adding AND inbetween the values, didnt work either..

    What is the correct way to do this?

  2. #2
    SitePoint Enthusiast
    Join Date
    Feb 2012
    Location
    United Kingdom
    Posts
    77
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    You can use the || operator to enable different values to be selected:

    PHP Code:
    $query mysql_query("SELECT * FROM textareas WHERE Section = 'forskola-allmant' || Section = 'forskola-miljo'") or die(mysql_error()); 


Bookmarks

Posting Permissions

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