Click here to Skip to main content
15,917,610 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
SELECT State_Mast.Name as state, Led_Grp.Name as ledger From State_Mast, Led_Grp

when I execute above query i get a output table with fields state and ledger in which
data is repeated several times .

for eg
state_mast.name has a entry say "XYZ" and ledger.name has entries "123" "456"

the output should be a table with fields state and ledger, with state having only 1 entry "XYZ" and ledger having 2 entries "123","456".
Instead I am getting a table having fields state and ledger with state having entries "XYZ" repeated several times and ledger having entries "123","456" repeated several times

What I have tried:

Nothing much, there is no relation between the two tables. I just need records from fields of two different table in on table.
Posted
Updated 4-Dec-17 11:03am
v4

1 solution

Quote:
INNER JOIN and , (comma) are semantically equivalent in the absence of a join condition: both produce a Cartesian product between the specified tables (that is, each and every row in the first table is joined to each and every row in the second table).

See MySQL :: MySQL 5.7 Reference Manual :: 13.2.9.2 JOIN Syntax[^].
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900