I have a variable $id which gives me the id of the current article and this can help me to make an update query in my database on current article. This is my code: I don’t get any errors but my code is still not working… Answer Your correct code is here: ; from the end of sql is not
“You tried to execute a query that does not include the specified aggregate function”
SELECT SUM(orders.quantity) AS num, fName, surname FROM author INNER JOIN book ON author.aID = book.authorID; I keep getting the error message: “you tried to execute a query that does not include the …
Best Practice For Lookup Tables In SQL
I am fairly new to SQL so apologies if this questions sounds odd. I keep coming across the issue of poor data. As an example London could be stored as LON, London UK, London England etc. Prior to …
Concatenate string in statement that assigns a variable in PostgreSQL
I am trying to convert SQL Server procedure to PostgreSQL. In the SQL Server procedure There are statements like below SET @val = ‘(‘ + @someval + ‘)’ So in postgresql I wrote as below SET val …
How do you leave comments in SQL Server 2008 R2 view with SSMS?
According to multiple sources Microsoft , SQL Server Administration Blog | zarez.net adding comments to SQL and doing so with SSMS is a piece of cake. And for the most part they are probably right. But when I log in and create a view I have been unable to leave comments in it. If I use two hyphens (–) t…
Performance for using 2 where clauses in LINQ
In LINQ-to-Entities you can query entities by doing: I know that behind the scenes it will be translated to SQL to something similar to: However is there a difference (with respect to performance) if I write: Will it be translated to the same SQL query? From my understanding .Where() will return IEnumerable&l…
Can I use VARCHAR as the PRIMARY KEY?
I have a table for storing coupons/discounts, and I want to use the coupon_code column as the primary key, which is a VARCHAR. My rationale is that, each coupon will have a unique code, and the only commands I will be running are SELECT … FROM … WHERE coupon_code=’..’ I won’t be …
SQL – Select records for the same day between particular data range [closed]
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers. Questions concerning problems with code you’ve written must describe the specific problem — and include valid code to reproduce it — in the question itself. See SSCCE.org for guidance. Closed 8 years ag…
Replace Parameters in SQL query text with XXXXX
I m writing a small utility that captures and logs SQL statements, but will have to remove sensitive data from the Query text and replace with with some dummy text (i.e:XXXXX). What is a good way to parse the SQL query in java and replace parameters value? for example: replace with Answer Using JSQLParser (V0…
SQL use CASE statement in WHERE IN clause
Is it posible to use case in where in clause? Something like this: DECLARE @Status VARCHAR(50); SET @Status=’published’; SELECT * FROM Product P WHERE P.Status IN (CASE WHEN @Status=’…