query help

  • Hello,

    I would like create a query returning the following:

    Select 2 fields from patient table

    and inner join a secondary table to return all fields from

    that table that have a character LIKE 'x'

    Please help and thank you in advance.

    Sorry about the newbie question...

  • SELECT A.Column1, A.Column2, B.*

    FROM Table A INNER JOIN Table B ON A.PrimaryKey = B.PrimaryKey

    WHERE B.Column LIKE 'X%'


    Kindest Regards,

  • The question is a little bit confusing . If ALL FIELDS should be checked for 'x' as a first character, then the WHERE condition should something like

    WHERE (B.Column1 LIKE 'x%') AND (B.Column2 LIKE 'x%') AND ... AND (B.ColumnN LIKE 'x%').

    If 'x' may appear at any position, then the check should be LIKE '%x%'. Beware, this does not use any indexes on searched columns.

    More information about the table structure will be helpfull.

    Regards,

    Goce Smilevski.

  •  

    Hm, maybe you wanted to select 2 colums from patients, then do the join using those two columns (or primary keys instead?) on rows cointaining "%x%" and return all those rows?

    ***

  • What I am trying to accomplish is to return all the fields in the second table that contain the letter 'X' without having to type all the fields in the statement.  The second table has approxamatley 45 columns.  I don't to have to type tumor.field1, tumor.field2, tumor.field3, tumor.field4...... LIKE 'X%'.  I would like to state:

    SELECT Pat.Field1, Pat.Field2,Tum.*

    FROM PAT INNER JOIN TUM

    ON PAT.PK = TUM.PK

    WHERE TUMOR.* LIKE 'X%'  hoping it will return all fields that have 'X' in the column...

    Hopefuly this makes a little more sense.  Thank you.

Viewing 5 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic. Login to reply