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 6 2018, 12:24 AM
Post
#2
|
Programming Fanatic Group: Members Posts: 1,981 Joined: 27-April 13 From: Edinburg, Texas Member No.: 19,088 |
Create a new PHP script and place this code in it.
CODE <?php Be sure to put your database login information in. Let me know the results of this test.$conn = new mysqli("host", "user", "pass", "dbname"); if($conn->connect_error) { die("Can't connect to database: " . $conn->error); exit(); } $sql = "SELECT b.CustomersArtitemid, b.nameof, b.Priceofart, b.Dateof, b.termsof, b.Ageof, b.graphic, b.emailadd, a.Customersitemid, a.email, a.name, a.Price, a.terms, a.Age, a.Date, a.Softbought FROM Customers a INNER JOIN CustomersArt b ON a.Customersitemid = b.CustomersArtitemid"; if(!$result = $conn->query($sql)) { die("Database Query Error: {$conn->error}"); exit(); } $rows = mysqli_fetch_all($result); var_dump($rows); $result->close(); $conn->close(); ?> |
Lo-Fi Version | Time is now: 18th April 2024 - 05:45 AM |