fessouy
fessouy

Reputation: 3

why is mysql giving me a mix of my database values

so I made a database which contains 2 tables, table1 and table2. if I use SELECT*FROM table 1 I get somthing like:

name1,adres1,city1

name2,adress2,city2

and if i use SELECT*FROM table 2 I get somthing like:

name1,gender1,hobies1

name2,gender2,hobbies2

but when i use SELECT*FROM table1,table2 I get:

name1,adres1,city1,name1,gender1,hobies1

name1,adress1,city1,name2,gender2,hobbies2

name2,adres2,city2,name2,gender2,hobies2

name2,adress1,city2,name1,gender1,hobbies1

why is this happening?

Upvotes: 0

Views: 23

Answers (1)

alegria
alegria

Reputation: 1145

What you're experiencing is simply the result of Cartesian Product. You are selecting every possible combination of the rows in those two tables.

Upvotes: 0

Related Questions