How does one in oracle find the greatest of three columns in say 10 rows? The requirement is I have three dates column and I have need to find greatest of three columns in 10 rows. I know greatest will find in one row. How? Answer How about
How to Insert combining two different selects in SQL Server?
I want to insert into a table as part of a longer procedure using SQL Server 2008. The table for the insert has two columns, itemID and tag. The tag part is selected from an input parameter (xml) …
How can I return 3 COUNT columns from the same table when JOIN with other tables as well?
I would like to know how I can return several COUNTs for the following: I have 27 work sites, each site has an employee with a contract, I have wrote a script to return one actual column of data (…
Laravel: getting a single value from a MySQL query
I’m trying get a single value from MySQL database using laravel but the problem I’m getting an array . this is my query result in MySQL command line: my laravel function: expected $data value is a string with value= Admin but what i get is : [{“groupName”:”Admin”}] Answer E…
SQL: Insert into table and return new index?
I have a database with auto-increment index. When I inserting a new item in the table, I don’t know the index number. Is there a way to return new index of my item simultaneously? I could assume that …
Laravel – seeding large SQL file
A memory exhaustion happens when I run my DB seed script in production. Below is my seed script. So what I did was add a no-limit on my seed script. The problem now is that when I run the script it logs the output into the terminal the content of the SQL script (which is very, very big). Is there
PostgreSQL: Create table if not exists AS
I’m using PostgreSQL and am an SQL beginner. I’m trying to create a table from a query, and if I run: CREATE TABLE table_name AS (….query…) it works just fine. But then if I add ‘if not …
Extract Parameters from pdo query
I have this query using pdo: SELECT * FROM users WHERE name LIKE :name AND age > :age1 AND age < :age2 how can I extract the parameters from this query with a regular expression in order to …
Join Two Non Related Tables
I have two tables Like A and B. Each have one column (ID) in ascending order. I want to join tables LIKE C Table. Datas are not statical but in A and B the row counts are always equal. I’ve tried join statements but couldn’t find out. Thanks for your help. Answer If you’re using a database t…
Alter column default value
I know you can change the default value of an existing column like this: But according to this my query supposed to work: So here I’m trying to make my column Not Null and also set the Default value. But getting Incoorect Syntax Error near CONSTRAINT. Am I missing sth? Answer I think issue here is with …