SitePoint Sponsor |
|
User Tag List
Results 1 to 8 of 8
Thread: if then statement trouble
-
Sep 20, 2007, 11:41 #1
- Join Date
- Apr 2007
- Posts
- 690
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
if then statement trouble
I'm trying to say
If the username appears in the following list:
$sql = "SELECT * FROM authorize AS u_one INNER JOIN authorize AS u_all ON u_all.department IN ( u_one.department , u_one.department2 , u_one.department3 , u_one.department4 , u_one.department5 , u_one.department6 ) WHERE u_one.username = '$_SESSION[user_name]' AND NOT u_all.lockedstatus = 'LOCKED'";
and also in this
SELECT * FROM here
Then display all information from that user in the here table.
-
Sep 20, 2007, 11:56 #2
- Join Date
- Aug 2007
- Location
- GR
- Posts
- 352
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Very cryptic, does it work?
-
Sep 20, 2007, 12:08 #3
- Join Date
- Apr 2007
- Posts
- 690
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Well, If it did I wouldn't be asking for help now would I? :P
-
Sep 20, 2007, 12:48 #4
- Join Date
- Sep 2007
- Location
- Vancouver, BC, Canada
- Posts
- 233
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
could you explain the purpose of your sql statement?
* @location Vancouver, BC, Canada
* @name Steve
* @job PHP/MySQL, Drupal, WordPress Developer
-
Sep 20, 2007, 12:52 #5
- Join Date
- Apr 2007
- Posts
- 690
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
The purpose of that sql statement is to weed out unwanted usernames..
-
Sep 20, 2007, 12:59 #6
- Join Date
- Aug 2007
- Posts
- 365
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
If you are trying to find users in
SELECT * FROM here
which are also in
SELECT * FROM authorize AS u_one INNER JOIN authorize AS u_all ON u_all.department IN ( u_one.department , u_one.department2 , u_one.department3 , u_one.department4 , u_one.department5 , u_one.department6 ) WHERE u_one.username = '$_SESSION[user_name]' AND NOT u_all.lockedstatus = 'LOCKED'
You could try and use a LEFT JOIN, so something like
SELECT * FROM here LEFT JOIN authorize ON here.username=authorize.username WHERE authorize.username IS NOT NULL
-
Sep 21, 2007, 10:29 #7
- Join Date
- Apr 2007
- Posts
- 690
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
So this?
SELECT * FROM authorize AS u_one INNER JOIN authorize AS u_all ON u_all.department IN ( u_one.department , u_one.department2 , u_one.department3 , u_one.department4 , u_one.department5 , u_one.department6 ) WHERE u_one.username = '$_SESSION[user_name]' AND NOT u_all.lockedstatus = 'LOCKED' SELECT * FROM here LEFT JOIN authorize ON here.username=authorize.username WHERE authorize.username IS NOT NULL;
-
Sep 21, 2007, 12:04 #8
- Join Date
- Aug 2007
- Location
- GR
- Posts
- 352
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
DELETE FROM tbl1,tbl2,tbl3,tbl4 WHERE username = 'username' ??
On the other hand, post your tables and what exactly you want to do.
Joining the same table is not a good option.
Bookmarks