samuel_lopez Posted October 29, 2015 Share Posted October 29, 2015 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 10This is my current sqlSelect * from student where year = '".$year."' and age ="5" and favorite number = "10"My error is when I enter year != CollegeIt has still output Quote Link to comment Share on other sites More sharing options...
budimir Posted October 29, 2015 Share Posted October 29, 2015 (edited) What do you get when you echo $year = $_POST['year'];? Also, can you give us error which you recive? Edited October 29, 2015 by budimir Quote Link to comment Share on other sites More sharing options...
maxxd Posted October 29, 2015 Share Posted October 29, 2015 This is off topic, true, but why does the column 'year' (which is a reserved word in MySQL, by the way) not contain a year value? 'College' isn't a year, 2015 is a year. Quote Link to comment Share on other sites More sharing options...
benanamen Posted October 29, 2015 Share Posted October 29, 2015 (edited) 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 October 29, 2015 by benanamen Quote Link to comment Share on other sites More sharing options...
Barand Posted October 29, 2015 Share Posted October 29, 2015 ... the column 'year' (which is a reserved word in MySQL, by the way)... It is a keyword but it is not reserved, therefore permitted as an identifier http://dev.mysql.com/doc/refman/5.5/en/keywords.html Quote Link to comment Share on other sites More sharing options...
maxxd Posted October 29, 2015 Share Posted October 29, 2015 It is a keyword but it is not reserved, therefore permitted as an identifier http://dev.mysql.com/doc/refman/5.5/en/keywords.html You are correct - keyword, not reserved word. Of course, I still think it's a bad idea to use as an identifier. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.