SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Member
    Join Date
    Apr 2001
    0 Post(s)
    0 Thread(s)

    Thanks in advance for anyone will help ..


    I have a table (adam) and 3 fields x,y,z
    I need to show all records that (y=a and z=1) and (y=b and z=0)
    I tried many queries but always error or showing All the records that match Any of the two Criteria .. or I got a message Your SQL-query has been executed successfully
    without showing any records !

    Last query I tried was

    SELECT * FROM adam WHERE ((y=a AND z=1)AND(y=a AND z=0))


    Second question .. how can I add 1 to the numaric records .. for example I need to add 1 to all records in field z
    now for example
    x y z
    1 a 0
    2 a 1
    3 b 4
    so I need the z records to be 1, 2, 5

    Thanks for your time ..


  2. #2
    ********* Callithumpian silver trophy freakysid's Avatar
    Join Date
    Jun 2000
    Sydney, Australia
    0 Post(s)
    0 Thread(s)
    1) You need to use the "OR" logical operator. If either condition 1 OR condition 2 is true then the row is included in the result set.

    SELECT *
    FROM adam
    WHERE (y=a AND z=1)
    OR (y=a AND z=0)

    2) Believe it or not the people at IBM who came up with the SQL language had a reasonable grasp of maths I make that cyncical remark because ppl all to often forget that MySQL is a *language* as well as a database with built in mathematic functions, regular expressions, etc.

    UPDATE adam
    SET z = z + 1

    3) This is your first post. Welcome to sitepoint. If you feel like it you can post in the Introductions forum and introduce yourself.


Posting Permissions

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