How to SELECT all fields from two tables?
Moderator: General Moderators
fixed it - it was here:
$query= "select * from `customers`, `orders2` where `orders2`.realname = '$realname' and `customers`.realname = `orders2`.`realname`";
changed to:
$query= "select * from `customers`, `orders2` where `orders2`.realname = `customers`.realname and `customers`.realname = `orders2`.`realname`";
Now I just have to config the HTML output...
boy, thanks a million!
this is a fantastic resource for someone trying to learn the how-to's
$query= "select * from `customers`, `orders2` where `orders2`.realname = '$realname' and `customers`.realname = `orders2`.`realname`";
changed to:
$query= "select * from `customers`, `orders2` where `orders2`.realname = `customers`.realname and `customers`.realname = `orders2`.`realname`";
Now I just have to config the HTML output...
boy, thanks a million!
this is a fantastic resource for someone trying to learn the how-to's
LAST QUESTION
Now, what's the best way to search for single orders?
whole new can of worms?
whole new can of worms?
- feyd
- Neighborhood Spidermoddy
- Posts: 31559
- Joined: Mon Mar 29, 2004 3:24 pm
- Location: Bothell, Washington, USA
it's actually not all that bad.
This should be the same query you just wrote, in a different lookUsing that, is a natural extension.
This should be the same query you just wrote, in a different look
Code: Select all
SELECT
*
FROM
`customers`
INNER JOIN
`orders2`
ON
(
`customers`.`realname` = `orders2`.`realname`
)Code: Select all
SELECT
*
FROM
`customers`
INNER JOIN
`orders2`
ON
(
`customers`.`realname` = `orders2`.`realname`
)
WHERE
`specificField` = 'some value'Thanks to all
all is well
many thanks to all who helped me here.
mc
many thanks to all who helped me here.
mc
strange results
one thing that's wierd...
when I query for a report, I get duplicates of orders when they're by the same customer - wondering how to configure it so I only get one result for each order...
query I'm using :
when I query for a report, I get duplicates of orders when they're by the same customer - wondering how to configure it so I only get one result for each order...
query I'm using :
Code: Select all
echo "<a href=\"order_admin.php\">Admin</a><br>";
$realname2 = $_POST["realname"];
include("host.php");
$dbh=mysql_connect ($host, $user, $password);
$link = $dbh;
@mysql_select_db($dbname) or die( "Unable to select database");
$sql = "SELECT * FROM `customers`INNER JOIN `orders2` ON (`customers`.`realname` = `orders2`.`realname`) WHERE `customers`.`realname`= '$realname2' ORDER BY orders2.date desc";
$query=$sql;
$result = mysql_query($query) or die(mysql_error());
if (is_resource($result)){
if (mysql_num_rows($result)){
etc
Last edited by michlcamp on Fri Aug 26, 2005 10:53 am, edited 2 times in total.
please use
Code: Select all
orCode: Select all
tags around your code