views:

26

answers:

2

I need to get a SQL Query that I can execute to extract certain data. Here are the details:

  • DB Type: MySQL
  • DB Name: adminDB
  • Table Name: licenseinfo
  • Field Name: LicenseNumber

So the data in the LicenseNumber Column looks like this: ( this is just a sample there are 300,000 Records)


SSCY-334-0W2-5AA

SSCY-238-2W1-5F9

SSCY-378-0W5-5BD

SSCY-312-061-5PO

SSCF-323-0R2-5FW

SSCF-548-2U1-5OL

SSCF-332-0G5-5BY

SSCF-398-041-5PE


I need to extract all records that have SSCF in the LicenseNumber

I tried query builder in SQLYog but I was getting syntax errors.

Can Someone please write this query for me.

thanks

+2  A: 

Assuming the letters are always at the start:

SELECT * FROM licenseinfo WHERE LicenseNumber LIKE 'SSCF%'

If you really do mean that the text 'SSCF' can be anywhere in the license number you can use LIKE '%SSCF%' instead, but if your sample data is representative, I think this will return the same results but be slower.

Mark Byers
If there is an index on LicenseNumber the fixed at the front version will use the key. Otherwise you'll get no help from the index.
Epsilon Prime
@Epsilon Prime: +1 good point. This could make the speed difference quite large.
Mark Byers
Thank you very much! It worked!
DevCompany
+2  A: 

I think this should work:

select * from licenseinfo where LicenseNumber like 'SSCF%'
Blorgbeard
Thank you very much! It worked!
DevCompany