I want to select records from two tables. These two tables have the prefix "shop\_". 

How do I select the records for both shops in a sql statement?

My current statement:

```
// Select
$stmt = $mysqli->prepare("SELECT name, html_id, price FROM database_name WHERE TABLE_NAME LIKE 'shop%'");
$stmt->execute();
$result = $stmt->get_result();
while($row = $result->fetch_assoc())
{
    $arr[] = $row;
}

$name = [];
foreach($arr as $arrs)
{
    $name[] = array(0 => $arrs['name'], 1 => $arrs['html_id'], 2 => $arrs['price']); //here
}
$stmt->close();

print_r($name);

```

The mysql php current **error** is:

```
Fatal error: Uncaught Error: Call to a member function execute() on boolean in C:\wamp642\www\webcart\search.php on line 17 and line 17 is: $stmt->execute();

```

I can get the tables to "show" with this command:

```
$stmt = $mysqli->prepare("show tables like '%shop%'");

```

But it doesn't get the records, just an object I think. 

The output of "show tables like '%shop%'" prints 2 arrays just like it should, but the arrays are empty with no data/records. 

I'm thinking it's the sql statement that needs work. Thanks.

**EDIT:** 

I've also tried:

```
$stmt = $mysqli->prepare("SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA='feeds' AND TABLE_NAME LIKE 'shop%'");

```

**EDIT: The contents of search.php**

```
<?php 

include 'define.php';

$mysqli = new mysqli($host, $db_user, $db_password, $db_database);
if($mysqli->connect_error)
{
    ?><script>var profiles_delete_modal_1 = ' Error 3: Problem deleteing profile. Make sure database login credentials are correct.';</script>
    <script>$(".modal").css({"opacity":"1", "z-index":"100"});$(".modal_mid").html("<pre>" + profiles_delete_modal_1 + "</pre>");setTimeout(function(){$(".modal").css({"opacity":"0", "z-index":"-100"});},5000);</script><?php
    exit;
}

$shop = 'shop';
// Select
//$stmt = $mysqli->prepare("show tables like '%shop%'");
//$stmt = $mysqli->prepare("SELECT * FROM feeds WHERE TABLE_NAME LIKE 'shop%'");
$stmt = $mysqli->prepare("SELECT name, html_id, price FROM database_name WHERE TABLE_NAME LIKE 'shop%'");
$stmt->execute();
$result = $stmt->get_result();
while($row = $result->fetch_assoc())
{
    $arr[] = $row;
}

$n=0;
$name = [];
foreach($arr as $arrs)
{
    $name[] = array(0 => $arrs['name'], 1 => $arrs['html_id'], 2 => $arrs['price']); //here
    $n++;
}
$stmt->close();

print_r($name);

```

**and the contents of define.php:**

```
$www_dir = 'webcart';
$url_root = 'http://localhost/' . $www_dir . '';
$www_dir_slash = $_SERVER['DOCUMENT_ROOT'] . '' . $www_dir . '/';
$host = 'localhost';
$db_user = 'webcart_admin';
$db_password = 'asd123';
$db_database = 'shop';

$_SESSION['host'] = $host;
$_SESSION['db_user'] = $db_user;
$_SESSION['db_password'] = $db_password;
$_SESSION['db_database'] = $db_database;

```

**EDIT** 

From going on the answer stated below I've been able to create a string like this: 

```
SELECT name, html_id, price FROM shop_a UNION shop_b

```

however it won't execute properly. 

This is my code:

```
$stmt = $mysqli->prepare("SELECT name, html_id, price FROM shop_a UNION shop_b"); 
$result = $stmt->execute();

```

It gives the following error:

```
Fatal error: Uncaught Error: Call to a member function execute() on boolean in C:\wamp642\www\webcart\search.php on line 43

```

**EDIT** Got it. 

I'll post the answer up soon. The statement goes like this: 

```
"SELECT name, html_id, price FROM shop_a UNION SELECT name, html_id, price from shop_b"

```