I’m using MySQL with Vb.Net 2010 and Crystal Reports and to be honest I’m a complete noob when it comes to using Sql Queries. The problem is, I want to generate a report that will show the service fee from a transaction a person made while also showing the items bought, and their quantity and prices, basically a bill. I created a command from the data source I created in crystal reports and it contains this query:
SELECT t.transaction_code,t.fee,t.service_type,t.date_sched,total_bill, s.item_code, s.quantity_sold, i.item_description, i.price, CONCAT(p.fname,' ',p.mi,' ',p.lname),p.address FROM tbl_transaction AS t, tbl_sale AS s, tbl_item AS i, tbl_profile as p WHERE t.transaction_code = '{?trans_code}' AND s.transaction_code = t.transaction_code AND i.item_code = s.item_code AND p.id='{?p_id}'
It all works fine if I use that, the report shows everything like the persons name, transaction code, service type and its fee as well as all the items bought and the total bill. The problem is, if in that certain transaction, the said person only required services and did not buy any items, the report will just be blank. What I want is that the report should still be able to display the person’s name, transaction code, service type and its fee, etc., even without buying an item. I know it’s kind of hard to understand and it’s also hard for me to explain, but I really need help right now.
Since I can’t post images yet since I’m a new user. I’ll just post a link to where I uploaded the structures of my tables:
http://oi42.tinypic.com/xogw9k.jpg
I also have a table called link_profile_transaction which does what it says and another table for the services which is linked to the services and fee from the transaction table(tbl_transaction) though it isn’t included in the query.
http://oi41.tinypic.com/fqm2b.jpg
The links are legit and safe.
You must left join the items table to the service table.
Not really certain about the schema of your table, I am providing below for you to edit if it does not work as is.