mysql,sql,join,inner-join,select-statement
Maybe you can use group_concat, this join all values to one column. select a.*, group_concat(b.ItemId) joined from tableA a inner join tableB b on a.customerId = b.customerId group by a.customerId, a.customer, a.company Result: CUSTOMERID CUSTOMER COMPANY JOINED XXX001 XXX Company Name 600278,WH15 02 XXX002 YYY Company Name 600000 SQL Fiddle...
sql,sql-server,stored-procedures,output-parameter,select-statement
If you are looking at returning the testId and provided you have only one testId for the match criteria - you can just use the following as your select statement - SELECT @RecordsAffected = t1.TestID FROM tblWOSampleTest t1 JOIN tblTest t2 ON t1.TestID=t2.TestID; WHERE @WOID = t1.WOID AND @SampleID =...
sql,sql-server,select-statement
So you want a cross join of all books and all renters, adding a column that displays the RentalDate (if any) for a given combination of BookID and Renter? Try this: SELECT B.BookId, R.RentedBy, BR.RentalDate FROM Books AS B CROSS JOIN (SELECT DISTINCT RentedBy FROM BookRentals) AS R LEFT JOIN...