Results 1 to 7 of 7
  1. #1
    Join Date
    May 2007
    Posts
    139

    Unanswered: expected the result to return for this email(primary key) 2 rows(as many as table2

    in a Mysql VIEW I used "join" to join two tables

    ...table1 join table2...

    table2 has 2 entries(rows) and table1 has also 2 entries join by email(for a particular email), expected the result to return for this email(primary key) 2 rows(as many as table2 has for this email) return double 4 rows, in other words two rows have appeared twice,... the other data(customers) that had 1 in each table appeared normally as one row... well?

  2. #2
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    could you repeat the question please

    perhaps with sample data
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  3. #3
    Join Date
    May 2007
    Posts
    139
    yyy something like:

    SELECT yyy(field1), field2, field3 from table where field=666; // I look for yyy make field1(=email) only one in a given result set even have more entries...well?

  4. #4
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    that made even less sense than your first post, sorry

    please, show sample data
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  5. #5
    Join Date
    Feb 2008
    Location
    Japan
    Posts
    3,483
    Quote Originally Posted by lse123 View Post
    in a Mysql VIEW I used "join" to join two tables

    ...table1 join table2...

    table2 has 2 entries(rows) and table1 has also 2 entries join by email(for a particular email), expected the result to return for this email(primary key) 2 rows(as many as table2 has for this email) return double 4 rows, in other words two rows have appeared twice,... the other data(customers) that had 1 in each table appeared normally as one row... well?
    Primary key is unique by its definition.
    So, if there are two rows having identical key(email), there may be another column(say second_key) and (email, second_key) is unique.
    If the table has no such other column, you had better to change the table design.

  6. #6
    Join Date
    May 2007
    Posts
    139
    I mean keyword in front of a field make it unique, what the keyword(yyy in example)?

  7. #7
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    Quote Originally Posted by lse123 View Post
    I mean keyword in front of a field make it unique
    there is no such thing

    you could use the DISTINCT keyword, but it will apply to all columns in the SELECT clause
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

Posting Permissions

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