Page 1 of 1

MySQL Query Help

Posted: Fri Mar 28, 2008 7:00 pm
by Cosizzle
First time here so "Hello"

I've created a forum that registers data to a Database once its filled out. However besides the error checks on blank fields, Im also wanting to error check two separate fields that will error check against information within the database already.

For my setup I've created two tables. One holds the information received from he PHP script. The other Table has the information in it that the PHP script will error check against.

For sake of confusion the two columns that the PHP script error checks against are "dCode" & "VIN"
Right now the problem(s) I am currently having are:
1. The dCode and VIN fields of the PHP script have to be correct to a certain extent but not 100% SO as long as the person knows a dCode and a VIN then they can log in. My problem here, is because its within a table the Query I have running now checks to see if dCode and VIN are beside one another.

Code: Select all

 
SELECT user_id FROM ErrorCheck WHERE (dCode='3313' AND VIN='5J6RE')
    SELECT user_id FROM ErrorCheck WHERE (dCode='$dc' AND VIN='$vin')
 
Question: Is it possible to make a query that can search two different user_id's and combine them as one.

2. Because I only need the 1st five characters of the VIN I only need to error check against that. The VIN it self is around 17-20 characters. I've created this Query to error check against that.

Code: Select all

 
SELECT * FROM ErrorCheck WHERE MATCH (VIN) AGAINST ('5J6RE%')
    SELECT * FROM ErrorCheck WHERE MATCH (VIN) AGAINST ('$vin%')
 
Ideally - both one and two will have to work with one another but that can wait

Thank you very much in advance!

Re: MySQL Query Help

Posted: Sat Mar 29, 2008 3:39 pm
by Christopher
You can use LEFT(VIN, 5)='$vin' in your query to check against part of a field.