I am using a set of SQL LIKE conditions to go through the alphabet and list all items beginning with the appropriate letter, e.g. to get all books where the title starts with the letter “A”: That’s fine for letters, but how do I list all items starting with any number? For what it’s worth this is on a Postgres
Best way to test if a row exists in a MySQL table
I’m trying to find out if a row exists in a table. Using MySQL, is it better to do a query like this: SELECT COUNT(*) AS total FROM table1 WHERE … and check to see if the total is non-zero or is …
Can MySQL replace multiple characters?
I’m trying to replace a bunch of characters in a MySQL field. I know the REPLACE function but that only replaces one string at a time. I can’t see any appropriate functions in the manual. Can I replace or delete multiple strings at once? For example I need to replace spaces with dashes and remove other punctuation. Answer You can
How to detect and remove a column that contains only null values?
In my table table1 there are 6 columns Locations,a,b,c,d,e. Locations [a] [b] [c] [d] [e] [1] 10.00 Null Null 20.00 Null [2] Null 30.00 Null Null Null i need the result like …
MySQL: select the closest match?
I want to show the closest related item for a product. So say I am showing a product and the style number is SG-sfs35s. Is there a way to select whatever product’s style number is closest to that? …
How to insert a blob into a database using sql server management studio
How can I easily insert a blob into a varbinary(MAX) field? As an example: thing I want to insert is: c:picture.png the table is mytable the column is mypictureblob the place is recid=1
CREATE DATABASE using file in default path
I want to create an SQL script that creates a database. Right now, I have this: CREATE DATABASE [Documents] ON PRIMARY ( NAME = N’Documents’, FILENAME = N’Documents.mdf’) LOG ON ( NAME = N’…
How do I compare two columns for equality in SQL Server?
I have two columns that are joined together on certain criteria, but I would also like to check if two other columns are identical and then return a bit field if they are. Is there a simpler solution than using CASE WHEN? Ideally I could just use: Answer What’s wrong with CASE for this? In order to see the result,
Duplicate a record in MySQL
I have a table and I want to duplicate specific rows in the table. I know this is not the best way to do things but we are looking for a quick solution. Here’s something harder than I initially …
SQL : BETWEEN vs =
In SQL Server 2000 and 2005: what is the difference between these two WHERE clauses? which one I should use on which scenarios? Query 1: Query 2: (Edit: the second Eventdate was originally missing, so the query was syntactically wrong) Answer They are identical: BETWEEN is a shorthand for the longer syntax in the question that includes both values (EventDate