Skip to content
Advertisement

INSERT with SELECT

I have a query that inserts using a SELECT statement: Is it possible to only select “name, location” for the insert, and set gid to something else in the query? Answer Yes, absolutely, but check your syntax. You can put a constant of the same type as gid in its place, not just 1, of course. And, I just made

Update statement using with clause

I have a script that uses a stack of with clauses to come up with some result, and then I want to write that result in a table. I just can’t get my head around it, could someone point me in the right direction? Here’s a simplified example that indicates what i want to do: The real thing has quite

how to sort order of LEFT JOIN in SQL query?

OK I tried googling for an answer like crazy, but I couldn’t resolve this, so I hope someone will be able to help. Let’s say I have a table of users, very simple table: and I have another table of their cars and their prices. Now what I need to do is something like this (feel free to rewrite): Which

Select 2 columns in one and combine them

Is it possible to select 2 columns in just one and combine them? Example: select something + somethingElse as onlyOneColumn from someTable Answer Yes, just like you did: If you queried the database, you would have gotten the right answer. What happens is you ask for an expression. A very simple expression is just a column name, a more complicated

Advertisement