Jump to content

Select data using where clause


samuel_lopez

Recommended Posts

Hi all. I have a day long solving this problem but any solution I have applied is not working.

I have database table named student

 

 

student

 

$year = $_POST['year'];

 

id      name          year                            age          Favorite number 

1       John           College                           5                     10

2       Carlo          College                           5                      10

3       Peter          College                           5                       10

4       Mae           College                            5                        10 

5       Den            College                           5                        10

 

 

 

I want to select all student that there year is college and age is 5 and favorite number is 10

This is my current sql

Select * from student where year = '".$year."' and age ="5" and favorite number  = "10"


My error is when I enter year != College

It has still output 

Link to comment
Share on other sites

You dont make sense, you say

 

I want to select all student that there year is college

 

Then you say

 

My error is when I enter year != College. If you want where it does NOT EQUAL college use <> .

 

 

Select * from student where year <> '".$year."' and age ="5" and favorite number  = "10"

Edited by benanamen
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.