Creating a view from multiple tables |
Creating a view from multiple tables |
tudsy |
Aug 5 2018, 11:32 PM
Post
#1
|
Advanced Member Group: Members Posts: 246 Joined: 30-September 14 Member No.: 21,611 |
Hi
I have 4 tables, CustomersArt,Customers,subscribers and emailcomm. My question is, how do i create a view from these 4 tables with the column email ? I have done a view from one table (see below): $query = "CREATE VIEW ecovib2d AS SELECT email FROM CustomersArt"; Any help will be appreciated. |
CharlesEF |
Sep 7 2018, 11:46 PM
Post
#2
|
Programming Fanatic Group: Members Posts: 1,981 Joined: 27-April 13 From: Edinburg, Texas Member No.: 19,088 |
Telling me about an error but now showing the query doesn't help much. The query should look like this:
CODE $sql = "(SELECT * FROM `Customers` WHERE `email` = '$email') If you also need to know where each row comes from then the query can be change to show this.UNION (SELECT * FROM `CustomersArt` WHERE `emailadd` = '$email') UNION (SELECT * FROM `emailcomm` WHERE `emailaddress` = '$email') UNION (SELECT * FROM `subscribers` WHERE `emailsub` = '$email')"; |
Lo-Fi Version | Time is now: 13th May 2024 - 12:36 AM |