February 26, 2005 at 12:59 am
Hello,
I have six tables (COURSE, FACULTY, IS_QUALIFIED, IS_REGISTERED, SECTION, and STUDENT). What I need to do is create a query to display the course ID and course name for all courses with an ISM prefix. I have so far:
SELECT*
FROM COURSE, Course_ID, Course_Name
My question is how do I create the last parameter that results in just courses with an ISM prefix?
Thanks
February 26, 2005 at 6:16 am
If I got your problem correctly,
u can use Like command
i.e.
Where Course_ID Liek 'ISM%'
is this the answer you are looking for
My Blog:
February 26, 2005 at 10:02 am
Hi Dinesh,
I have good news! This query works like a charm. I added DMC 4458 and ISM 4444 as new Course_ID’s and only ISM 4444 returned along with the other ISM’s. Thanks Dinesh for your help and input.
SELECT Course_Name, Course_ID
FROM COURSE
WHERE (Course_ID LIKE 'ISM%')
ORDER BY Course_Name DESC
Dennis
March 1, 2005 at 8:41 am
hi there
I think it would be quicker to use
where left(course_id,3)='ISM'
as this is a more exact match. Wildcards tend to slow things down
Ross
March 1, 2005 at 9:00 am
Thanks Ross,
It works great.
Dennis
March 1, 2005 at 9:49 am
Actually, LIKE 'something%' will perform better (only when you're looking from the beginning of the string - LIKE '%something%' will do a table scan).
This is because LIKE can use an index, if an appropriate one exists. The other string functions use table scans.
P
Viewing 6 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic. Login to reply