I was wondering if anyone can spot any mistakes in my sql statement. I would like it to insert a new record into my table if one doesn’t exists already. If it does exist then just update it. My primary key in the date field. Here is my statement as it appears in php and also the error I’m getting:
SQLalchemy specify which index to use
Is there a way in SQLalchemy to tell the query which index to use? The reason I need this is that the SQL queries it generates use the “wrong” index – there exists an index for exactly the two fields that I have and it doesn’t use it. Thanks! Answer I think you can use with_hint() for …
group rows in plain sql
I have a Table with columns Date and Number, like so: date Number 1-1-2012 1 1-2-2012 1 1-3-2012 2 1-4-2012 1 I want to make a sql query that groups the rows with the same Number and take the minimum date. The grouping only may occur when the value iof Number is the same as previous / next row. So
Issue creating table in MS SQL Database with Python script
The above code successfully connects to the database. The script also returns no errors when run, however when I go to check if the table was created, there are no tables in the SQL DB at all. Why is no table created and why is no error returned? Answer Each user in MS SQL Server has a default schema associat…
Delete with “Join” in Oracle sql Query
I am not deeply acquainted with Oracle Sql Queries, therefore I face a problem on deleting some rows from a table which must fulfill a constraint which includes fields of another (joining) table. In other words I want to write a query to delete rows including JOIN. In my case I have a table ProductFilters and…
Is there a way to change DATE format on?
I need to store some date in my SQL database, the problem is that the default storage is And I need My only solution was to store date as Varchars (10) and it’s working pretty well, but now I can’t order my queries by DATE, and I need to order them from the oldest to the newest… Answer There…
Query error with ambiguous column name in SQL
I get an ambiguous column name error with this query (InvoiceID). I can’t figure out why. They all seem to be joined correctly so why doesn’t SSMS know to display VendorID? Query: SELECT …
Export table description in PHPMyAdmin/MySQL
DESC table_name Above SQL allows me to get the table description in PHPMyAdmin. I want to export it to a text file or word file for the documentation. Is there a possible way to do it. Thanks.
How to count occurrences of a node in SQL XML?
I am trying to do a count on the number of occurrences of the “Colors” node but have been so far unsuccessful. Below is what I have tried so far. If I have the following logic: I get the following error: Msg 2389, Level 16, State 1, Line 50 XQuery [value()]: ‘value()’ requires a single…
Where to place limit clause?
I am trying to place a limit clause on the database query to only show the first 4 results. The current code I am working with is $categories_query = “select c.categories_id, cd.categories_name, …