Ask Me Help Desk

Ask Me Help Desk (https://www.askmehelpdesk.com/forum.php)
-   MySQL (https://www.askmehelpdesk.com/forumdisplay.php?f=442)
-   -   Join on first match? (https://www.askmehelpdesk.com/showthread.php?t=300751)

  • Jan 8, 2009, 12:25 AM
    psychlopes
    Join on first match?
    Hello all,

    Can someone tell me How I can join a table (A) on a table (B) on a sorted column using a join condition so that only the first match is selected as the joined record?

    For instance, I have:

    Table A

    Phone numbers
    983357654

    Table B
    Prefixes

    9833
    983
    98
    9

    I want to joib table A and B using the condition that the phone number is "LIKE" the prefix% . But I want only the first match , i.e. in this example 9833

    Any ideas?
  • Jun 10, 2009, 01:37 AM
    arun1028

    u can use as
    CREATE view anname
    as
    select firstcolomname,secondcolomname,
    from firsttablename JOIN secondtablename
    on firsttablename.UserID=secondtablename.UserID

  • All times are GMT -7. The time now is 10:40 PM.