Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
AskSQLTeam
Ask SQLTeam Question
0 Posts |
Posted - 2002-06-03 : 08:41:47
|
| Jamie writes "The below SQL statement has 4 inc_desc fields. At the moment I am searching only one field for 'Smith' but is there any easy way of combining them as one field in the SQL statement and search just that? I have included my SQL statement below. Thanks Jamie SELECT i.incident_ref, i.date_logged, i.incident_id, u.assyst_usr_sc, u.assyst_usr_n, u.assyst_usr_id, s.serv_dept_sc, s.serv_dept_id, s.serv_dept_n, i.inc_desc1, i.inc_desc2, i.inc_desc3, i.inc_desc4, i.aff_usr_name FROM incident i, serv_dept s, assyst_usr u WHERE i.ass_svd_id = s.serv_dept_id AND i.ass_usr_id = u.assyst_usr_id AND i.inc_desc1 LIKE '%Smith%' AND s.serv_dept_id IN (1, 37, 38, 49, 50, 51, 52, 53, 54, 55, 56, 57, 61) AND i.inc_status = 'o' ORDER BY I.incident_ref DESC " |
|
|
LarsG
Constraint Violating Yak Guru
284 Posts |
Posted - 2002-06-03 : 08:50:37
|
| easy enough?WHERE i.ass_svd_id = s.serv_dept_id AND i.ass_usr_id = u.assyst_usr_id AND (i.inc_desc1 LIKE '%Smith%' or i.inc_desc2 LIKE '%Smith%' or i.inc_desc3 LIKE '%Smith%' or i.inc_desc4 LIKE '%Smith%' )AND s.serv_dept_id IN (1, 37, 38, 49, 50, 51, 52, 53, 54, 55, 56, 57, 61) AND i.inc_status = 'o' ORDER BY I.incident_ref DESCUsing i.inc_desc1 + i.inc_desc2 + i.inc_desc3 + i.inc_desc4 like '%Smith%'wouldn't be the same criteria. |
 |
|
|
|
|
|
|
|