SitePoint Sponsor

User Tag List

Results 1 to 3 of 3

Hybrid View

  1. #1
    SitePoint Member
    Join Date
    Mar 2011
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    multiple AND statement error

    Hi guys,

    I have problems with multiple "AND" statement from 2 tables.

    I have this WORKING mysql query :
    $items = "SELECT * FROM products, users WHERE users.email='email@email.com' AND products.code=users.code ORDER BY time DESC LIMIT 30";

    And when I add one more statement it just returned error:
    $items = "SELECT * FROM products, users WHERE users.email='email@email.com' AND products.code=users.code AND products.pricea < products.priceb ORDER BY time DESC LIMIT 30";

    "AND products.pricea < products.priceb" this give me problems.

    Any solution for this?

    Thanks

  2. #2
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,246
    Mentioned
    59 Post(s)
    Tagged
    3 Thread(s)
    please show the error message that you got
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"

  3. #3
    SitePoint Member
    Join Date
    Mar 2011
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by r937 View Post
    please show the error message that you got
    It's weird!! (I'm new to mysql) but now it's working..

    I use this query..

    $items = "SELECT * FROM products, users WHERE products.pricea < products.priceb AND users.email='email@email.com' AND products.code=users.code ORDER BY time DESC LIMIT 30

    I rearrange the condition accidentally.


Tags for this Thread

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
  •