By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,963 Members | 1,046 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,963 IT Pros & Developers. It's quick & easy.

equalise data from one table column to another table column

P: 30
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.  

Share this Question
Share on Google+
2 Replies


Expert 100+
P: 1,031
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

P: 30
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.