equalise data from one table column to another table column

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Bala Kumaran
    New Member
    • Jan 2013
    • 30

    equalise data from one table column to another table column

    hello friends!

    Can anyone help me to matching one column databases from another colunm databases.

    For example:

    The below table name is domains

    Code:
    ----------------------------------------------------------
    id | name   |  domains
    ---|--------|---------------------------------------------
    1  | tamil  |  example1.com
         |                    |
    2  | bala   |  example2.com
         |                    |
    3  | ramu   |  example3.com
         |                    |
    4  | ravi   |  example4.com
         |                    |
         |                    |
         |                    |
    ----------------------------------------------------------

    The below table name is : notifications

    Code:
    ----------------------------------------------------------
    id | domain        |  notifications
    ---|---------------|--------------------------------------
    1  | example1.com  |  notification1
         |                           |
    2  | example2.com  |  notification2
         |                           |
    3  | example3.com  |  notification3
         |                           |
    4  | example4.com  |  notification4
         |                           |
         |                           |
         |                           |
    ----------------------------------------------------------

    My question is,

    Tamil, bala, ramu, ravi are the users in my website
    every one having each domains in their account which is mentioned in the domains table

    tamil is having domain name example1.com,
    bala is having domain name example2.com,
    ramu is having domain name example3.com,
    ravi is having domain name example4.com


    I want to get the result of notifications column from the notifications table if any domains are matching from the domains column in the domains table with the domain column of the notification table.

    Finally, I want get the notification results

    (I am creating this for who are the users logged with their account notifications should get matching domains from first table to second table of the user)

    I think my question is understood to everyone, please help me friends...

    Thank You
    Last edited by Rabbit; Jun 16 '14, 04:19 PM. Reason: Please use [code] and [/code] tags when posting code or formatted data.
  • Luuk
    Recognized Expert Top Contributor
    • Mar 2012
    • 1043

    #2
    This wil show the notifications for 'tamil'
    Code:
    SELECT d.name, d.domains, n. notifications
    FROM domains d
    LEFT JOIN notifications n
      ON n.domain=d.domains
    WHERE d.name='tamil'
    Last edited by Luuk; Jun 15 '14, 04:05 PM. Reason: little typing error corrected.

    Comment

    • Bala Kumaran
      New Member
      • Jan 2013
      • 30

      #3
      Thank you brother for your quick reply. It works very well.

      Thank u

      Comment

      Working...