#1
  1. No Profile Picture
    Senior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2000
    Posts
    89
    Rep Power
    15
    Hi,

    I wondered how to check a selection ( select * from db where this and that) if two rows have the same values in tow columns.

    In numbers: check if row(1) AND row(2) have the same value in col(x) AND in col(y).

    Thanks in advance
    Otis
  2. #2
  3. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2000
    Posts
    1
    Rep Power
    0
    You have to use the same table twice and give it a different alias, as below:

    select a.*, b.*
    from table1 as a, table2 as b
    where b.column_x = a.column_y

    hope that helps...
    Narendra Jain
  4. #3
  5. No Profile Picture
    Senior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2000
    Posts
    89
    Rep Power
    15
    Thanks.

  6. #4
  7. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2000
    Posts
    15
    Rep Power
    0
    How about comparing each item against a single record on your table?
  8. #5
  9. No Profile Picture
    Senior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2000
    Posts
    89
    Rep Power
    15
    I don't quite get what you mean. I'll explain my situation a bit more.
    I'm working on a timetable. Students visit the site, choose the lectures, hit a button and there we go, a neat timetable.
    Now, as some lectures are at the same time I want those out of the result to "echo" them in, let's say red.
    I'm using a php-class, which generates a table, using "x" and "y" coordinates for table row/cell. Found it somewhere an modified it slightly. The query I ran is this:
    " $result1 = mysql_query("SELECT a.x, a.y, b.x, b.y FROM plan AS a, plan AS b WHERE a.x=b.x AND a.y=b.y"); "

    So could you give me a query-example of what you meant?

    Thanks for the help
    Otis




    [This message has been edited by Otis (edited November 24, 2000).]

Similar Threads

  1. Replies: 0
    Last Post: January 21st, 2004, 07:57 AM
  2. Zip code validation
    By krwyth in forum MySQL Help
    Replies: 2
    Last Post: January 5th, 2004, 02:29 PM
  3. Selecting top two values for each set
    By dpeters in forum Database Management
    Replies: 5
    Last Post: December 30th, 2003, 01:45 PM
  4. Selecting all columns EXCEPT some.
    By peenie in forum MySQL Help
    Replies: 3
    Last Post: November 18th, 2003, 11:28 AM
  5. w3c strict errors (10), css, and js questions
    By WorldBuilder in forum CSS Help
    Replies: 12
    Last Post: November 6th, 2003, 05:48 AM

IMN logo majestic logo threadwatch logo seochat tools logo