468,470 Members | 2,080 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,470 developers. It's quick & easy.

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

Expand|Select|Wrap|Line Numbers
  1. ----------------------------------------------------------
  2. id | name   |  domains
  3. ---|--------|---------------------------------------------
  4. 1  | tamil  |  example1.com
  5.      |                    |
  6. 2  | bala   |  example2.com
  7.      |                    |
  8. 3  | ramu   |  example3.com
  9.      |                    |
  10. 4  | ravi   |  example4.com
  11.      |                    |
  12.      |                    |
  13.      |                    |
  14. ----------------------------------------------------------

The below table name is : notifications

Expand|Select|Wrap|Line Numbers
  1. ----------------------------------------------------------
  2. id | domain        |  notifications
  3. ---|---------------|--------------------------------------
  4. 1  | example1.com  |  notification1
  5.      |                           |
  6. 2  | example2.com  |  notification2
  7.      |                           |
  8. 3  | example3.com  |  notification3
  9.      |                           |
  10. 4  | example4.com  |  notification4
  11.      |                           |
  12.      |                           |
  13.      |                           |
  14. ----------------------------------------------------------

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
Jun 15 '14 #1

✓ answered by Luuk

This wil show the notifications for 'tamil'
Expand|Select|Wrap|Line Numbers
  1. SELECT d.name, d.domains, n. notifications
  2. FROM domains d
  3. LEFT JOIN notifications n
  4.   ON n.domain=d.domains
  5. WHERE d.name='tamil'
  6.  

2 1039
Luuk
1,043 Expert 1GB
This wil show the notifications for 'tamil'
Expand|Select|Wrap|Line Numbers
  1. SELECT d.name, d.domains, n. notifications
  2. FROM domains d
  3. LEFT JOIN notifications n
  4.   ON n.domain=d.domains
  5. WHERE d.name='tamil'
  6.  
Jun 15 '14 #2
Thank you brother for your quick reply. It works very well.

Thank u
Jun 15 '14 #3

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

reply views Thread by NPC403 | last post: by
1 post views Thread by kmladenovski | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.