Skip to content
Advertisement

SQL LIKE condition to check for integer?

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

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

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? …

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

Advertisement