Click here to Skip to main content
15,071,928 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
private void btnNew_Click(object sender, EventArgs e)

           sql = " SELECT  br.`AccessionNo`, `BookTitle`, `BookDesc` as Description,Concat (`Firstname`,' ', `Lastname`) as 'Borrower',`NoCopies`, `DateBorrowed`, `DueDate` FROM `Borrow` br,`Books` b,`Student` bw  WHERE br.AccessionNo=b.AccessionNo AND br.`BorrowerId`=bw.`BorrowerId` ORDER BY BorrowId Desc";
           Load_ResultList(sql, dtg_BlistOfBooks);

           sql = "SELECT AccessionNo From books Where Status = 'Available'";
           autocomplete(sql, txtAccesionNumBorrow);

           sql = "SELECT BorrowerId From Student";
           autocomplete(sql, txtBorrowerId);

What I have tried:

I use the || concatenation operator but still error
Updated 8hrs ago

1 solution

Most likely, you need to use a JOIN to combine the table information rather than trying to just reference multiple tables.

The problem is that SELECT ... FROM Table1, Table2 combines all row combinations: for three rows in each table there are 9 output rows.

A JOIN allows you to use the DB's relational properties and return three rows of related info:
SELECT * FROM Table1 t1
JOIN Table2 t2 ON t1.ID = t2.ID
See here: SQL Joins[^]

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