I have a query: SELECT brand FROM products WHERE brand='”.$brand.”‘ AND category='”.$id.”‘”.$categories_list.” The idea is to get a count of the total products within a category or across multiple categories by a category ID or IDs by a brand number. The code as it sits: It works correctly when only counting a single category. However, it displays incorrect counts when
Tag: where-clause
In the SQL Query I couldn’t get truly data
Hi, I have a facilities table. I want to know which hotel_id has 2 facilities at the same time. with that no record. Answer Your query does not work because you are looking for rows that satisify both conditions simultaneously, which cannot happen. You need to look across rows of the same group. Instead, you can filter on rows that
Filter a condition after aggregate function in SQL Server?
I’ve got database of flights and I want it to return average of delay, but I want it to filter ‘origin = ‘SFO” after counting average of arr_delay_new. If I use WHERE or HAVING it counts the average with condition origin = ‘SFO’. How to make it count avg first and filter later? This one has no condition origin =
get null values with decode
I have a table with names, where the name can be null. If I want to get all the rows with null names, I do the following: but I want to make sure that if I specify a value it will get the non-null values and if it won’t get the null values So I get the values that are
MySQL – Select on varchar column with 0 (zero) as criteria returns all rows?
Sorry in advance – this seems like a really dumb question. But… If I run a select query on a varchar() column, but use zero for the column value in the where clause – why does it return all rows? …
Comparing two dates in Oracle after using TO_DATE function
I have the following Oracle Query that is converting todays date and the date field from the table into the same format. However, when trying to compare the two they aren’t coming up as equal. The cast is used on the field in my table, both these return. However, when adding the following where statement no rows are returned. I
Difference between NVL and OR in SQL oracle
Hej guys, could someone explain to me difference between NVL() and OR in below query : Number of rows: 44937 and Number of rows: 44782 Why we have this difference: 155 rows? i built a few query based on nvl and notice that issue and going to switch to OR, but I really want to know, why it such a
Multi-parameter search with mysql and node.js
Let me preface by saying I’m very new to SQL (and back end design) in general. So for those annoyed with noob questions, please be gentle. BACKGROUND: I’m trying to build a product test database (storing test data for all our products) where I want a user to be able to refine a search to find test data they actually
Conditional Query Using “AS” field
Above you can see my code. It is currently returning exactly the output I want when you remove the “WHERE” function. I’m adding the “WHERE” function and attempting to access the new column I made called “NPO”. It seems as if the column does not exist to the SQL editor, but it does exist when the query is ran. How
How to search for multiple words with one query?
I am trying to make a simple php search using the following query. This works perfectly however the query only gives results for the first word. Would there be a way to get a combined result for all …