I’m trying to run the following PHP script to do a simple database query: This produces the following error: Query failed: ERROR: relation “sf_bands” does not exist In all the examples I can find where someone gets an error stating the relation does not exist, it’s because they use uppercase letters in their table name. My table name does not
How to determine the number of days in a month in SQL Server?
I need to determine the number of days in a month for a given date in SQL Server. Is there a built-in function? If not, what should I use as the user-defined function?
MS Access query: why does LIKE behave differently when being called from VB6 app?
I don’t do a lot of coding with VB6, but I’m updating an existing app now and just encountered a snag. I figured out the problem. In VB6, queries must use the % wild card when using LIKE, but in MS …
How do I UPDATE a row in a table or INSERT it if it doesn’t exist?
I have the following table of counters: I would like to increment one of the counters, or set it to zero if the corresponding row doesn’t exist yet. Is there a way to do this without concurrency issues in standard SQL? The operation is sometimes part of a transaction, sometimes separate. The SQL must run unmodified on SQLite, PostgreSQL and
MySQL query to extract first word from a field
I would like to run a query that returns the first word only from a particular field, this field has multiple words separated by spaces, I assume I may need to carry out some regex work to accomplish this? I know how to do this using a few ways in PHP but this would best be carried out on the
Find the smallest unused number in SQL Server
How do you find the smallest unused number in a SQL Server column? I am about to import a large number of manually recorded records from Excel into a SQL Server table. They all have a numeric ID (…
How can I find duplicate entries and delete the oldest ones in SQL?
I’ve got a table that has rows that are unique except for one value in one column (let’s call it ‘Name’). Another column is ‘Date’ which is the date it was added to the database. What I want to do is find the duplicate values in ‘Name’, and then delete the ones with the oldest dates in ‘Date’, leaving the
Search for “whole word match” in MySQL
I would like to write an SQL query that searches for a keyword in a text field, but only if it is a “whole word match” (e.g. when I search for “rid”, it should not match “arid”, but it should match “a …
How to execute an .SQL script file using c#
I’m sure this question has been answered already, however I was unable to find an answer using the search tool. Using c# I’d like to run a .sql file. The sql file contains multiple sql statements, some of which are broken over multiple lines. I tried reading in the file and tried executing the file using ODP.NET … however I
How do I spool to a CSV formatted file using SQLPLUS?
I want to extract some queries to a CSV output format. Unfortunately, I can’t use any fancy SQL client or any language to do it. I must use SQLPLUS. How do I do it?