Need some help on a simple query

  • 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

     

  • 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: http://dineshasanka.spaces.live.com/

  • 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

  • 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

  • Thanks Ross,

    It works great.

    Dennis

  • 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