Click here to Skip to main content
15,881,413 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
i have two table invoce,customer

invoice table with invoice no,cumtomerid,date
customer table with cumtumer id,and custumer name,customer mobile

i performering searchng by a textbox
user can search via invoice no or custumer name or customer mobile..
i have to retrieve invoice no,custumer name,customer mobile,date from database

i trying this query...

SQL
SELECT invoice.InvoiceNo, invoice.Date, Customer.Name,Customer.MobileNo FROM Customer inner JOIN invoice  on  invoice.CustomerID=Customer.CustomerID and invoice.InvoiceNo like'ajay%' or Customer.Name like'ajay%' or Customer.MobileNo like'ajay%'


where ajay is Customer Name
but its not provide appropriate answer

please gieve me solution of that problem
Posted
Updated 11-Nov-11 17:39pm
v2
Comments
Amir Mahfoozi 12-Nov-11 1:26am    
There is nothing mentioned here about pageindexchanging ! Please describe more about it...

SQL
invoice.InvoiceNo like'ajay%' or Customer.MobileNo like'ajay%'


how can you check Ajay with InvoiceNo, Mobile No ?
you should know Ajay is Customer name not Mobile No, invoice No.

change you way of accepting input from user. Use dropdownlist containing search fields CustomerName, InvoiceNo, Mobile No.
first select search criteria and then enter desired value in textbox.
 
Share this answer
 
Comments
Mehdi Gholam 12-Nov-11 0:34am    
OP : its query is correct,i was wrong with pageindexchanging.....
SELECT invoice.InvoiceNo, invoice.Date, Customer.Name,Customer.MobileNo FROM Customer, invoice where invoice.CustomerID=Customer.CustomerID and invoice.InvoiceNo like'' or Customer.Name like'ajay%' or Customer.MobileNo like''
use this query for your ques.
 
Share this answer
 
its query is correct,i was wrong with pageindexchanging.....
 
Share this answer
 
Comments
Mehdi Gholam 12-Nov-11 0:34am    
Use the comments on the specific solution, do not post solutions yourself.

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