Page 1 of 1

How do I write a query to achieve the following:

Posted: Tue Jun 15, 2004 5:48 am
by SFADuncan
I wish to extract everything from Web as a result of a username variable I have.

I have three tables:

User (username, password, bizname, etc etc)
Biz (bizname, bizstatus, add1, add2 etc etc)
Web (bizname etc, and other fields)

I have the Username variable (as a result of my login script, which should equal user.username) and wish to extract everything from Web where user.bizname=biz.bizname and then subsequently where biz.bizname=web.bizname.

Simon

Posted: Tue Jun 15, 2004 6:51 am
by Grim...
Okay.
How about you select everything from the username row and put bizname into a variable, say $biz. The do an SQL query something like

Code: Select all

SELECT * FROM Biz WHERE bizname = '$biz'
Remember to use [php_man]add_slashes[/php_man]:

Code: Select all

<?php
$biz = addslashes($biz);
?>

Posted: Tue Jun 15, 2004 10:34 am
by pickle

Code: Select all

SELECT
    Web.*
FROM
    User,
    Biz,
    Web
WHERE
    Biz.bizname = User.bizname AND
    Web.bizname = Biz.bizname
I'm unsure about the select clause - I've never used that [table_name].* format but I imagine it should work.