mySQL substring and mid function
Posted on 2009-04-11
I have a database table to store sale details with invoice IDs. The format for these invoice IDs are as follows : SEUSC003-1/CEI000013. The first S refers to Sale, EU refers to End User, SC003 refers to supplier, the number 1 refers to invoice number for that particular supplier. CEI000013 refers to customer code. I want a query to compare whether SC003 have been entered or not and I want that number 1 to auto increment later on. I'm using this on VB6 btw. I have the following query just to check whether SC003 have been entered or not:
select * from saledetails where supplier_code = substr(invoice_id, 8, 4).
is the query correct? It should return all the saledetails where supplier code is (eg. SC003) right? or is my query totally wrong?
Thx for the help experts