I am trying to get a count of all items sent to a supplier based on the purchase order they are assigned to. But I can’t seem to get the control to show a number of items based on the purchase order instance – it keeps throwing either a #name? or #error! message in the text box when the form
Tag: sql
SQL to check if database is empty (no tables)
I need to check if a database is totally empty (no tables) using an SQL query. How can this be done? Thanks for the help! Answer will return the actual number of tables (or views) in your DB. If that number is 0, then there are no tables.
Deferrable Constraints in SQL Server
Do any versions of SQL Server support deferrable constraints (DC)? Since about version 8.0, Oracle has supported deferrable constraints – constraints that are only evaluated when you commit a …
Delete duplicate records from a SQL table without a primary key
I have the below table with the below records in it I dont have any primary key in this table .But i have the above records in my table already. I want to remove the duplicate records which has the same value in EmpId and EmpSSN fields. Ex : Emp id 5 How can I frame a query to delete
How do I subtract using SQL in MYSQL between two date time values and retrieve the result in minutes or second?
I want to subtract between two date time values using SQL in MySQL such that I get the interval in minutes or seconds. Any ideas? I want to run a SQL query that retrieves uses from a database who have logged in like 10 minutes from the time. Answer There are functions TIMEDIFF(expr1,expr2), which returns the …
MySQL INTO OUTFILE override existing file?
I’ve written a big sql script that creates a CSV file. I want to call a cronjob every night to create a fresh CSV file and have it available on the website. Say for example I’m store my file in ‘/…
What SQL would I need to use to list all the stored procedures on an Oracle database?
What SQL would I need to use to list all the stored procedures on an Oracle database? If possible I’d like two queries: list all stored procedures by name list the code of a stored procedure, given …
Sqlalchemy complex in_ clause with tuple in list of tuples
I’m trying to find a way to cause SQLAlchemy to generate a query of the following form: select * from t where (a,b) in ((a1,b1),(a2,b2)); Is this possible? If not, any suggestions on a way to …
Using column alias in WHERE clause of MySQL query produces an error
The query I’m running is as follows, however I’m getting this error: #1054 – Unknown column ‘guaranteed_postcode’ in ‘IN/ALL/ANY subquery’ My question is: why am I unable to use a fake column in the where clause of the same DB query? Answer You can only use column ali…
Copy Data from a table in one Database to another separate database
Basically I have a two databases on SQL Server 2005. I want to take the table data from one database and copy it to another database’s table. I tried this: This didn’t work. I don’t want to use a restore to avoid data loss… Any ideas? Answer SELECT … INTO creates a new table. You…