SQL Syntax Error - pls help

saroren

New Member
select tr_nbr , "act-ship"
from pub.tr_hist , pub.job
where tr_type = 'ISS-SO'
and tr_effdate >= '10/01/06 '
and job.workorder like tr_nbr;

Above Query gives me syntax error. its because of
"and job.workorder like tr_nbr" . Is there any other way to change it.


Thanks
 

BCM

Member
In SQL language the operator "like" is used to compare character string data.
Is the column named "tr_nbr" a character datatype or is it numeric?

Which column contains part of the other column: Is the value of tr_nbr a substring in workorder or is workorder a substring in tr_nbr?

Here is an example. For this example we will assume that the value of column tr_nbr is equal to the value of workorder with some other characters appended.
workorder = "12345"
tr_nbr = "12345001"

The comparison would be: tr_nbr LIKE "12345%".
The where clause would be tr_nbr LIKE (workorder + '%').

If either of these columns - tr_nbr or workorder - are numeric columns, then you will need to cast them as varchars.
Where cast(tr_nbr as varchar(10)) LIKE (cast(workorder as varchar(10)) + '%').
If there are many records, this will not be very fast because indexes will not exist for the cast values.
 

Girish Girigowd

New Member
Try a SQL join statment. I also don't understand why you have the second table in quotes? is that a typo? Your query looks pretty straight forward.
 
Top