I have a query like this: The output of the query will be something like this, basically a CODE and the respective COUNT, for example: After this first query, I have a foreach that will iterate the result of the query above. Inside the foreach, for each result of the query above, I want to get some information that is
Tag: string
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 …
SQL CASE statement needs to handle Text
Apologies if this has been asked before – I’ve spent a couple of hours searching but not found anything that’s helped. It’s quite simple really – I’ve been asked to create a query which includes a field that when it was set up (not by me) was created as a VARCHAR instead of an INT. I need to do some
Using LIKE in SQL with multiple search terms
I’m doing a basic SQL course and learning the basics currently and having issue with filtering: Task: list all the rows from TableName where the columnName field content does not contain any of the following words: ‘stack’ or ‘overflow’ or ‘exampleword’. -> I get it to work properly with just a single value, but when I try adding more words
Cannot figure out the issue with this SQL CASE
The issue i am facing is: “SYNTAX_ERROR: line 7:6: All CASE results must be the same type: boolean” I have also joined the table in a previous sub query casting it as a varchar, so there shouldn’t be any issues with this. Anyone have any ideas? For context i am trying to populate a field that would return a blank
Split SQL string with specific string instead of separator?
I have table that looks like: I want to split the string to this: My goal is to show ID and all the strings starting with 1 with just the next number after them. I filtered all rows without ‘%1,%’ and I don’t know how to continue. Answer If you use SQL Server 2016+, you may try to use a
SQL Query “like” operator error, when the field is null
this query returns 421 records: Now when I implement the “like” operator, it returns 349 records, it is not taking into account the records with the field “invoice_number” in null:
Get Values between Each Comma in Seperate Row in SQL Server
I need to insert multiple rows in a database table from a single string. Here is my string it will be comma-seperated values Current string: What I want is that batch 1 should be ignored or removed and remaining part should be added into the SQL Server database as a separate row for after each comma like this Table name
Sql reverse search for products and discounts
I have two table, one for products, and one for discounts. Discounts table look like: ID | Name | Percentage | Product Name Search Param ——————————————————-…
columnA like %columnB
I’m trying to do select * where column1 = % column2 %. this is my query The error: The data types varchar and text are incompatible in the add operator. Answer You can cast the text to a varchar(max): Or, if b.Client is a text too: Notes (most of which already were commented): text is deprecated; you want to use