1
vote
0answers
23 views

Merge/combine two queries with different dates

I have one query that runs a SUM statement based on daterange 1, and worked fine, and another query that run same SUM statement, but on a different date range. I would like to merge/combine the two ...
12
votes
4answers
3k views

Why use WHERE 1 or WHERE 1=1?

Usually, if conditions are not required in our query statements, we don't use a WHERE clause. But I see a WHERE 1 clause being used in many places, even where other conditions are not present. Why ...
0
votes
1answer
76 views

MySQL: fetch multiple global status and system variable in a single query

When we execute SHOW global status; or SHOW variables; we get list of 291 and 278 records in the resultset. For performance perspective, only few of them are much important. I have to fetch these ...
1
vote
1answer
2k views

mysql trigger to insert/update date column from datetime column

probably simple question but can't get it to work: I have a table with two datetime columns. In order to set up a date index and have simpler queries, i have added two date columns next to them. ...
1
vote
1answer
51 views

Conditional Counting

I'm analyzing a database of login records for a university and I'm trying to write a query that will give me an idea as to how many users are using the labs for short bursts, verse a more extended ...
-1
votes
2answers
410 views

Infinite Loop While Running Query

When I run this query from the command line, it continuously loops. I'm not sure why this is occurring. Could anyone explain this to me, and please offer a fix. I will be using a query similar to ...
2
votes
3answers
942 views

Can I make sure two columns dont have the same value

If I have a table that looks like this CREATE TABLE foo ( id INT NOT NULL AUTO_INCREMENT, aa INT NOT NULL, bb INT NOT NULL, PRIMARY KEY (id), UNIQUE KEY (aa, bb), CONSTRAINT aa_ref ...
1
vote
0answers
36 views

How does MySQL 5.1 use indexes?

I've read the docs for MySQL v5.1.x on how about the indexes are used, but I'm not sure I understood it properly. Suppose having the following MySQL table: CREATE TABLE IF NOT EXISTS ...
1
vote
2answers
395 views

Lost connection to MySQL server during query

Here is a part of my query SELECT * INTO OUTFILE 'Target_File_Name' FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"' LINES TERMINATED BY '' FROM (SELECT 'Start time','Calling no','Called ...
3
votes
1answer
537 views

Is it possible to compare timestamps between rows?

I have a MySQL table reqs with (this is simplified from actual): | Field | Type | Null | Key | Default | Extra | ...