Is there a way to use shorthand for the following:
This would be rather handy when I want to filter out some of the results.Code:SELECT * FROM table WHEREcol != 'this' AND col != 'that'
Printable View
Is there a way to use shorthand for the following:
This would be rather handy when I want to filter out some of the results.Code:SELECT * FROM table WHEREcol != 'this' AND col != 'that'
I don't think so. You could use regex if you wanted but that would take longer.
What I mean is could I replace
with something likeCode:SELECT * FROM table WHERE col != 'this' AND col != 'that'
orCode:SELECT * FROM table WHERE col != 'this','this1','this2'
or evenCode:SELECT * FROM table WHERE col != 'this'||'this1'||'this2'
Code:SELECT * FROM table WHERE col != $array
No. You could use PHP to write the query - makes things like this a snap, if you're doing it dynamically/ more than once.
Bummer, I was hoping MySQL could use some shorthand similar to what PHP uses. For some of my larger scripts I do use PHP to dynamically write the queries. For my website search script the queries can be quite large and numerous depending on the terms and tables searched.
I don't have any experience with this, but if you have access to the MySQL server, you can write stored procedures. Don't know for sure, but I'm sure something like this could be done.
Well, there are two ways in which (at least in theory) this would be faster:
1. Faster to write.
2. Faster to process.
For (1), you can use PHP to generate it if you'd like.
For (2), I don't think that having more code in this case actually will be slower. MySQL is very efficient as-is, so a long query isn't a problem, but potentially making a multi-layered query (eg, a stored procedure) might end up being slower since there's more going on.
So, I don't think this would really help, except saving you the effort of automating the query in PHP.
I'm not really looking for something that is faster. I mostly was looking for a way to make the queries simpler. It would also make it a little easier to add filters to the query as new filters become needed.
This is in regards to my security monitoring script. I want to add ip addresses to the list that should not pop up in my table as potential security attacks. I have my own ip address and google's filtered out at the moment, but I am sure others will come up in the future.
Daniel - stored procedures are actually significantly faster than similar processing in PHP in most cases, since it's native. Obviously, there are a lot of things MySQL can't do for PHP, but the tasks it can do are faster.
Not to distract too much from the topic, but in what way are they faster? I'm probably missing something. Generally, if the PHP is badly written, I can see that being slow, but if it's a simple scenario where you just want to get a simple search done, I'm not sure why PHP would be slow there.