select statement showing multiple records

Results 1 to 2 of 2

Thread: select statement showing multiple records

  1. #1
    Join Date
    Dec 1969

    Default select statement showing multiple records

    sql="SELECT ForumName,ForumDescription,ForumOrder FROM Forums ORDER By ForumOrder ASC"<BR><BR>This statement is okay, but when I add this to the statement,<BR><BR>sql="SELECT CategoryName,CategoryOrder,ForumName,ForumDescript ion,ForumOrder FROM Category,Forums ORDER By CategoryOrder,ForumOrder ASC"<BR><BR>I get duplicate records displayed when I use this statement, there are no duplicate records in the databse, it will display the records 2 or 3 times. What can I do to get rid of this automatic duplication?

  2. #2
    Join Date
    Dec 1969

    Default No JOIN

    You need to learn the basics of SQL.<BR><BR>Without a JOIN between the two tables, you get the *cartesian product* of the two.<BR><BR>That is, you get every record in the first table matched with every record in the second table. If you have 7 records in the first table and 9 records in the second table, you will get 63 result records in your recordset.<BR><BR>If you don&#039;t *want* to JOIN the records, then you shouldn&#039;t put both tables into the same SELECT.<BR><BR>(You *might* want a UNION...see post below with that in the subject.)<BR>

Posting Permissions

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