kpetsche20 Posted December 8, 2008 Share Posted December 8, 2008 Can you use < and >= in a SQL WHERE statement? example mysql_query("SELECT * FROM shop WHERE date <= '".$todaysdate."'") Quote Link to comment https://forums.phpfreaks.com/topic/136137-can-you-use-and-in-a-sql-where-statement/ Share on other sites More sharing options...
flyhoney Posted December 8, 2008 Share Posted December 8, 2008 Yes Quote Link to comment https://forums.phpfreaks.com/topic/136137-can-you-use-and-in-a-sql-where-statement/#findComment-709995 Share on other sites More sharing options...
DarkWater Posted December 9, 2008 Share Posted December 9, 2008 Absolutely. My suggestion for dates, though, would be to have it set as a DATETIME column and use the MySQL NOW() function. Quote Link to comment https://forums.phpfreaks.com/topic/136137-can-you-use-and-in-a-sql-where-statement/#findComment-710126 Share on other sites More sharing options...
.josh Posted December 9, 2008 Share Posted December 9, 2008 Any reason why you decided to ask, before just trying it? Quote Link to comment https://forums.phpfreaks.com/topic/136137-can-you-use-and-in-a-sql-where-statement/#findComment-710129 Share on other sites More sharing options...
blueman378 Posted December 9, 2008 Share Posted December 9, 2008 hes like me... php can break things... i usually ask before i try if i think it could do something wrong... Quote Link to comment https://forums.phpfreaks.com/topic/136137-can-you-use-and-in-a-sql-where-statement/#findComment-710282 Share on other sites More sharing options...
corbin Posted December 9, 2008 Share Posted December 9, 2008 hes like me... php can break things... i usually ask before i try if i think it could do something wrong... But what could that statement possibly have broken? Selects alone are relatively harmless. Quote Link to comment https://forums.phpfreaks.com/topic/136137-can-you-use-and-in-a-sql-where-statement/#findComment-710291 Share on other sites More sharing options...
trq Posted December 9, 2008 Share Posted December 9, 2008 hes like me... php can break things... i usually ask before i try if i think it could do something wrong... Questions like these are exactly what the manual is for. Quote Link to comment https://forums.phpfreaks.com/topic/136137-can-you-use-and-in-a-sql-where-statement/#findComment-710302 Share on other sites More sharing options...
blueman378 Posted December 9, 2008 Share Posted December 9, 2008 yeah better safe than sorry... i was once writing a script because i was lazy, it was to search all files in a directory and rename them if they had a word. then go through all the files and search the text they contained and change the word inside them, it would do that recursivly for all sub directorys, i forgot to put in checking for the starting path so it went through and did it on every file it had access too. kinda scary when you see Access Denied in C:\windows ... so yeah thats my point. if he doesnt know sql very well he may not know the limits and lengths of the different statements Quote Link to comment https://forums.phpfreaks.com/topic/136137-can-you-use-and-in-a-sql-where-statement/#findComment-710303 Share on other sites More sharing options...
.josh Posted December 9, 2008 Share Posted December 9, 2008 I can understand not being sure about a command or something, and not wanting to mess something up. But that's what sandboxes are for. There's no reason why you need to test new script out on a live site, where if something goes wrong, you're screwed. But anyways, concerning this specific circumstance, I judge from the context of his post, that he knows that selecting stuff from his db is not going to damage things. After all, his question was not about the select. Quote Link to comment https://forums.phpfreaks.com/topic/136137-can-you-use-and-in-a-sql-where-statement/#findComment-710311 Share on other sites More sharing options...
msinternet Posted December 10, 2008 Share Posted December 10, 2008 And there was me thinking the occasional unintentional system format was part of a developers day... Quote Link to comment https://forums.phpfreaks.com/topic/136137-can-you-use-and-in-a-sql-where-statement/#findComment-711868 Share on other sites More sharing options...
revraz Posted December 10, 2008 Share Posted December 10, 2008 A simple search of MySQL Comparison Operators would have given you the answer. Quote Link to comment https://forums.phpfreaks.com/topic/136137-can-you-use-and-in-a-sql-where-statement/#findComment-711885 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.