![]() |
Where clause issue etc
Look I'm not feeling well, so here is the problem, it's saying that
my custom value is a column or something, something stupid. sql Code:
meh whatever by the way, $username value is in the $_COOKIE array. returns Unknown column 'Orc-Admin' in 'where clause' Never mind, I fixed it, yeha I forogot quotes are in it, yadda yadddda. so i suppose to have '$username' |
Anything within the $_COOKIE array can easily be spoofed and become an SQL Injection, it is still user input, so you would need to sanitise the variable before inserting it into your SQL Query.
Also, your column calls are ambiguous, you won’t need to use AS. Example, in this query: PHP Code:
username, email, and mid. And they would be exactly the same if you just used the column names without the alias: PHP Code:
|
Extending what Highway said above, you don't need to use a table alias when you're fetching values from a single table. You're only slowing down the query. So, the following is the same with what you wrote in the first place:
PHP Code:
|
theres no slow queries. lol
|
Just an advice: take the advices given to you and memorize them (or don't, I really don't care). Don't be a smart ass just for the sake of being one. Everybody here wants to help you, but they will stop doing that at one time or another, if you don't change your attitude.
|
Quote:
|
Quote:
Running them side-by-side, you may not notice a difference, in-fact, you probably won't. They may slow down by 0.01 seconds, which may seem insignificant, but that will make a big difference the more queries you have and the more traffic you have on your site that would cause these queries to run. A savings of 0.01 seconds is significant on my sites. But regardless, it’s a good idea to use correct practices, and xenon is correct regarding the usage of aliases. Aliases would be needed on multiple table queries, but are not needed when querying a single table. :) It’s not a *big* deal, but it’s still good practice. ;) |
Quote:
|
Not sure I understand the question. :|
|
Quote:
|
Ah, pretty much the way you did it...
Code:
SELECT column1, column2, column3Code:
SELECT a.column1, a.column2, b.field1, b.field2Code:
SELECT COUNT(post_id) AS total_postsThough I would need to see your COUNT query to understand what you’re asking. :) |
Quote:
Code:
SELECT COUNT(post_id) AS total_posts |
Depending on your table, and the data you are trying to obtain, you may need a GROUP BY clause, but a COUNT SELECT doesn’t require a GROUP BY in itself.
The data is key, it would depend on what kind of data you are trying to pull from your database. |
| All times are GMT. The time now is 03:59 AM. |
Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0