Question:
Visual Basic SQL QueryString - Statement?
Priya J
2010-08-11 07:23:39 UTC
Report.SQLQueryString = "SELECT Sales_master.`Invoice_no`, Sales_master.`Party_name`, Sales_master.`Sales_date`, Sales_master.`Item_type`, Sales_master.`Item_name`, Sales_master.`Qty`, Sales_master.`price_per_unit`, Customer_master.`City`, sales_item_description.`item_description` From (`Sales_master` Sales_master INNER JOIN `sales_item_description` sales_item_description ON Sales_master.`Invoice_no` = sales_item_description.`invoice_number`) JOIN `Customer_master` Customer_master ON Sales_master.`Custo_id` = Customer_master.`cutomer_id` Order By Sales_master.`Invoice_no` ASC, Sales_master.`Party_name` ASC "


I WANT FILTER INVOICE_NO="INV00112", HOW I INSERT WHERE OR HAVING COMMAND ABOVE STATEMENT COMMAND

THANKS.
Three answers:
TheMadProfessor
2010-08-11 08:01:24 UTC
As Alby said, you would put the WHERE prior to your ORDER BY. There's also no need to order by invoice number if you're only selecting a single one to begin with. You also might consider using a shorter alias for your table names...having the alias the same as the actual name doesn't buy you anything in readability:



Report.SQLQueryString = "SELECT s.Invoice_no, s.Party_name, s.Sales_date, s.Item_type, s.Item_name, s.Qty, s.price_per_unit, c.City, d.item_description… From Sales_master s JOIN sales_item_description d ON s.Invoice_no = d.invoice_number JOIN Customer_master c ON s.Custo_id = c.cutomer_id WHERE s.Invoice_number = "INV00112" Order By s.Party_name ASC "



If you're dealing with large table sizes, it's probably more efficient to use implicit joins instead of explict ones. That way, you can give the most limiting criteria first before you ever start joining tables:



Report.SQLQueryString = "SELECT s.Invoice_no, s.Party_name, s.Sales_date, s.Item_type, s.Item_name, s.Qty, s.price_per_unit, c.City, d.item_description… FROM Sales_master s, sales_item_description d, Customer_master c WHERE s.Invoice_number = "INV00112" AND d.invoice_number = "INV00112" AND s.Custo_id = c.cutomer_id Order By s.Party_name ASC "
kushiner
2016-10-01 02:35:28 UTC
you are able to probable acquire sq. utility from the internet someplace. seen consumer-friendly is distinctive: you're able to purchase it - attempt eBay. seen consumer-friendly is plenty extra stable to income. that's an entire featured programming language yet as quickly as mastered you are able to build finished information superhighway web pages. sq. is a less complicated language designed to decide on and study information from databases. i think you need to use sq. to study from get entry to databases (no longer Excel) yet you're able to probable be extra useful off to apply the equipment presented in get entry to.
Unca Alby
2010-08-11 07:42:57 UTC
"where" clause goes before the "order by" clause



where invoice_no='INV00112'

order by etc. etc. etc.


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...