sql

MySQL query to check for certain phrases (duplicate article, plagiarism)

Is there a way to check for multiple phrases in mysql? I need to check if an article have a duplicate version stored in mysql. This is the algorithm I first create an array of sentences that needed to be check (removing all non-alpha-numeric characters) Then Build the query (how?) After I get the result I compare if 50% of the sentenc...

Optimize a query that is using multiple left joins on the same tables

I've come across a query that is taking "too long". The query has 50+ left joins between 10 or so tables. To give a brief overview of the database model, the tables joined are tables that store data for a particular data type (ex: date_fields, integer_fields, text_fields, etc.) and each has a column for the value, a "datafield" id, and a...

Are there any toolsets/techniques to determine if SQL queries are functionally identical?

Hi all, new Stacker here! From a client I receive SQL queries that contain all sorts of redundant sub-SELECTs, generated by a builder in MS Access. I convert the SQL to Postgres, and it runs - but I know it's hopelessly inefficient. So, I set about optimising the query, and produce iterative improvements - and to determine whether each ...

Howto use Rollback/Commit in Oracle SQL

I am trying to utilize transaction functionality in Oracle SQL for the first time and can't seem to find a good explanation. I understand that starting a new session will begin a new transaction. I also understand that commit/rollback is used to end it. What I am trying to do is execute two statements and if I either of them fail, und...

Sql - Question on Cursors and variables

I am trying to use a cursor to move create a column that has all parts equal to a field that was before it. In example | column1 | column 2 | | 1 | a | | 2 | b | | 3 | c | would to go... | column1 | column2 | column3 | | 1 | a | b | | 2 | ...

What I must look into when porting big project from MySQL into Oracle?

So I have lots DB tables. I need to port my DB into Oracle. I have no problems on MySQL but must port onto oracle. so what are main tips&trics when going oracle from mysql? ...

MySQL Fulltext search phrases

How to use mysql fulltext search to search for phrases instead of like : SELECT description FROM t WHERE info LIKE "%Search phrase one%" OR info LIKE "%Phrase second%" OR info LIKE "%Another phrase with more words%" ...

Hibernate: how to specify clustered index annotation

I want to create an annotated class similar to that: @Entity @MappedSuperclass @Inheritance(strategy = InheritanceType.TABLE_PER_CLASS) public class SeriesMonitoringPointsTable { @Id @Column(name = ID, nullable = false) private Long id; public void setId( Long id ) { this.id = id; } } In this class I woul...

How to insert values into an MYSQL-Table by using Select-Statements

Okay, This one is pretty simmilar to my last one, but I don't get it...! I am trying the following: Insert into table b (Select column_1 from table_a where ID = 1), (Select column_2 from table_a where ID = 1), 0, (Select column_3 from table_a where ID = 1); But I always get a syntax-error...! I think it's quite logical what I...

Looking for a webbased SQL Game

A couple of weeks ago I found a great page. It basically was a level based SQL game. Starting off with simple queries you earned stars by completing tasks. The exercise declaration featured information about a certain database and what tables it features. You had to write statements/queries in the browser and solve the problem. The exerc...

How to indicate in postgreSQL command in which database to execute a script? (simmilar to SQL Server "use" command)

I have the following problem, I need to put in a script that is going to run before the new version is rolled the SQL code that enables the pgAgent in PostgreSQL. However, this code should be run on the maintenance database (postgres) and the database where we run the script file is another one. I remember that in SQL Server there is a ...

SQL Search Statement like Google?

Is there some kind of SQL Statement that I can used to do a search on 1 Column in my table that is similar to what I am looking for. Like if I am looking for something to do with a "Car" but I spell it as "Kar" it must return items of "car". Or If I am looking for "My Company" and I spell it as "MyCompany" it must still retun "My Com...

Warning: sqlite_query() expects parameter 1 to be resource, string given

ok so i've looked all over the place and cant find a solution that helps my case. I hope someone can help? basically i have this, and recieve "Warning: sqlite_query() expects parameter 1 to be resource, string given" relating to $dbresult line - so a problem with the query :( function Up(){ $dbquery = "DELETE FROM toolList WHERE toolI...

How to get the search words location from Sphinx search engine?

I use Sphinx to index HTML pages, giving different weights to title, description, etc. I'm looking for a way to get the search words location in the page from the results that I get from Sphinx. Meaning, if the wordset is "stack overflow program" and I have 5 documents that match, each of them was a match because it contained at l...

Forming SQL Query for Detail and Subtotals (MySQL)

I have a common SQL task but can't find a clear path to the solution. I have a table, downloads with the columns, download_date, image_file_id, credits. What I want at the end is the detail, plus a subtotal of credits for the day at the end of each day. E.g. 2010-10-06 123456 5 2010-10-06 234567 20 25 2010-10-07 234678...

To union or union all, that is the question...

I have two queries that I'm UNIONing together such that I already know there will be no duplicate elements between the two queries. Therefore, UNION and UNION ALL will produce the same results. Which one should I use? ...

SqlDependency vs SqlCacheDependency

What are the key differences between these and when should they be used? My initial understanding was that SqlCacheDependency used polling but I've read it doesn't have too for ASP.NET 2.0. I want to know which is most appropriate for caching of linq queries under ASP.NET web server. This will be ASP.NET 3.5. SqlCacheDependency http://f...

SQLITE corruption?- DELETE FROM toolList WHERE toolId=".$id

something is seriously wrong with my SQLITE I included echo $dbquery to see exactly what query is being run, and the statment seems correct - but when trying to view the db after, it comes up blank! I've checked the actuall file, and theres still data in the db file, so maybe it corrupting it? the query prints as: DELETE FROM tool...

SQL : Why doesn't this ROWNUMBER function work?

SELECT DateErrored FROM (SELECT Category, ROW_NUMBER (Partition by dateerrored ORDER BY category DESC)AS Row FROM AspErrors) AS LogWithRowNumbers WHERE Row >= 1 AND Row <= 10 ...

Could some interfaces in java.sql and javax.sql be re-used for NoSQL?

Other folks have asked about using SQL and NoSQL together, and subsequently whether there's a clean way of defining the access objects in a clean, generic way. My question is somewhat related -- which parts of java.sql and javax.sql can be re-used, and is there any plan for Oracle* to get into the NoSQL space and hopefully provide an AP...