In python, I am populating a SQLITE data base using the importmany, so I can import tens of thousands of rows of data at once. My data is contained as a list of tuples. I had my database set up with the primary keys where I wanted them.
Problem I ran into was primary key errors would throw up an IntegrityError. If I handle the except...
Which one is better in SQL ?
SELECT A.COL_A1, B.COL_B1 FROM TABLE1 A, TABLE2 B
WHERE A.COL_A1 = B.COL_B1
or:
SELECT B.COL_B1, A.COL_A1 FROM TABLE2 B, TABLE1 A
WHERE B.COL_B1 = A.COL_A1
more info..
http://publib.boulder.ibm.com/infocenter/iisclzos/v9r1/index.jsp?topic=/com.ibm.websphere.ii.federation.classic.tuning.doc/tuning/iiyfct...
This is my table:
CREATE TABLE t (id INT, parent INT, FOREIGN KEY(parent) REFERENCES t(id));
This is a collection of data I have:
id parent
1 NULL
2 NULL
3 1
4 1
I would like to select them and order like this:
id parent
1 NULL
3 1
4 1
2 NULL
I can't find a proper way to do it (in MySQL 5+)....
My problem:
I have a table with a Channel <int> and a Value <float> column, along with a timestamp and a couple of other columns with additional data. Channel is either 1 or 2, and there is either 1 or 2 rows that have everything except channel and value the same.
What I'd like to do is select this data into a new form, where the two ch...
I want get n-th to m-th records in a table, what's best choice in 2 below solutions:
Solution 1:
SELECT * FROM Table WHERE ID >= n AND ID <= n
Solution 2:
SELECT * FROM
(SELECT *,
ROW_NUMBER() OVER (ORDER BY ID) AS row
FROM Table
)a
WHERE row >...
So I have this SQL table that I need to update. Now we use a tool to do the process so if we just renamed the column then it wouldn't work because our tool would just drop the old column and add a new column with the new name, so we have to do it manually and enter this code into the build and exclude the table from our build.
The table...
Hi,
I have to store a tree in a database, so what is the best way to do this? Show the method you use and name its pros and cons. (I am using SQL Server 2005)
...
I have a big query as following, someone please tweak this query? i need to avoid this big group by ... :-)
SELECT COALESCE( SUM(total_retail), 0 ) total_retail,
COALESCE( SUM(meterial_sub_total), 0 ) meterial_sub_total,
COALESCE( MIN(po_template_group_by_code), 0 ) po_template_group_by_code,
COALESCE( MIN(po_te...
At the moment I want to have three columns in my database for Notes:
ID | Title | Content
The table could have a few hundred entries.
I want to be able to search for parts of the content. When Content is "this is a test sentence" and the user searches for "test" or even "te" then the row should be displayed.
Is it okay to store this i...
Hi,
[Below is the almost full Code modified. Currently shows illegal character error when being read].
I have a C# ASP.NET application which is currently reading an xml file from the file system and then loading it into a GridView control. In the grid I can Delete rows. There is also an file upload button below the grid which upload PDF...
Hi, I have a table of products in my sql database. Each product has an image and 4 thumbnails. These just store the filename of an image on the hard drive. The problem I have is that over time I have deleted thousands of products but the images still remain on the hard drive.
Now I need to build a script (in c# .net) to remove any orpha...
I have the following database table with information about people, diseases, and drugs:
PERSON_T DISEASE_T DRUG_T
========= ========== ========
PERSON_ID DISEASE_ID DRUG_ID
GENDER PERSON_ID PERSON_ID
NAME DISEASE_ST...
I got a really simple table structure like this:
Table Page Hits
id | title | parent | hits
---------------------------
1 | Root | | 23
2 | Child | 1 | 20
3 | ChildX | 1 | 30
4 | GChild | 2 | 40
As I don't want to have the recursion in my code I would like to do a recurisive SQL.
Is there any SELECT sta...
Now i am inputting some data from a form and i have a code to search the database inputting several parameters as input conditions. Now if one the parameters is null (i.e) the field is unchecked i need to replace that parameter with something say * so that the search query is unaffected. How would i do that?
@report = Problem.find(:all,...
I've been doing some research on finding an embedded database to be used with Silverlight/isolated storage. Everyone says SQLite will not work with Silverlight due to unmanaged code.
From my experience there is just a dll named System.Data.SQLite.DLL which I believe I either got from installed SQLite.NET or from the NHibernate build. ...
Hi, all!
MySQL table is like this (VoteID is PK):
VoteID VoteValue CommentID
1 -1 1
2 -1 1
3 1 1
4 -1 1
5 1 2
6 1 2
7 -1 2
I need a result:
CommentID Plus Minus
1 1 3
2 2 1
...
In SQL Server 2008, I am seeing some strange behavior when ordering NVARCHAR columns; here are a few quick use cases to demonstrate:
Case 1: ORDER on VARCHAR values:
SELECT t.Name
FROM
(
SELECT CAST('A' AS VARCHAR(500)) As Name
UNION SELECT CAST('-A' AS VARCHAR(500)) AS NAME
) As t
ORDER BY t.Name ASC
Which produces (my desired) o...
I'm trying to make a Teradata SQL query that will return the n-th chronological visit date for each user. E.g.,
user | visit_date
---------------------
a 1/1
b 1/10
c 1/20
a 1/3
a 1/4
b 1/5
c 1/15
b 1/9
> magic_query_for_Second_visit;
user | second
------------------
...
hello, i've got a SQL query, that works as follows:
SELECT TOP 100
Max(Table_ID) as Max_ID,
Col1,
Col2,
Col3,
COUNT(*) AS Occurences
FROM myTable
GROUP BY Col1, Col2, Col3
ORDER BY Occurences DESC
How can I write an identical Linq query?
The issue is, that as soon as i apply my grouping, I cannot access the non-grouped columns...
I have a situation where I would like to search single word.
For that scenario, which Query would be good from performance point of view?
Select Col1, Col2 from Table Where Col1 Like '%Search%'
Or
Select Col1, Col2 from Table Where Col1 CONTAINS(Col1,'Search')
...