Hi all,
I need SQL code for a query I need to do in Access. I have a table with multiple fields but I only need 2 fields for the query. 1 is a date field. let's call that one DateField. the other is a field that contains text, let's call lit TextField. I need a query that returns the following:
The COUNT of DateField (i.e. how many th...
My config table:
name | value
--------+------
version | 1.5.6
title | test
How I try and get it:
$getCfg = mysql_query("SELECT * FROM config");
$config = mysql_fetch_assoc($getCfg);
echo $config['title'];
Equals to:
Notice: Undefined index: title in C:\web\index.php on line 5
How would I get the value where the name is tit...
Having this table (sorry, cant seem to get a decent layout here):
PD Header Text Mask_Producer Mask_Dep Mask_Diam
----------------------------------------------------------------------------------------------
10 Producer Aproducer Aprod * *
10 Produ...
Let's say I have a table like this:
Customer,Invoice Type,Balance
A,Good,50
A,Good,10
A,Bad,20
B,Good,20
And I want to make a report like this:
Customer,Invoice Type,Balance,Total Adjusted Balance
A 40
Good
50
10
Bad
20
B 20
Good
20
Where total adjusted bal...
To simplify, if I had a table called 'employee':
id INT NOT NULL PRIMARY KEY,
salary FLOAT,
department VARCHAR(255)
I want to perform and query where I retrieve the minimum salary in each department.
So my query is something like this:
SELECT employee.ID, MIN(employee.salary), employee.department
FROM employee
GROUP BY employee.depar...
i need to move selected data from 800+ tables in one database to the same 800+ tables in another database in another server. The data i select is based on date fields of every table. So, if i say table 1 date from 01/01/10 to 01/15/10, then only that data i want to be copied into the other server's database table specified.
i hope i am n...
this is an attempted fix to a crystal reports use of 2 sub reports!
I have a query that joins 3 tables, and I wanted to use a pair of sub selects that bring in the same new table.
Here is the first of the two columns in script:
SELECT ea."LOC_ID", lo."DESCR", ea."PEGSTRIP", ea."ENTITY_OWNER"
, ea."PCT_OWNERSHIP", ea."BEG_BAL", ea."ADD...
I have a table PICTURES:
username varchar(50)
picture_id varchar(50)
datetime
...and I have a table FRIENDS:
user_1 varchar(50)
user_2 varchar(50)
datetime
When you have friends on the website your username goes in user_1, and your friend username's go in user_2. For each new friend a new row...
I want to show the 5 last ...
Hi guys:
We want to remove tons of obsolete data in a table, but this will lock table for a long while. Is is possible to use Cursor to delete, says, one hundred records per transaction in a while-loop ?
And where can I refer to the example?
...
Hai guys,
I have a table with a column named Is_Deleted and my query is
select Is_Deleted from Stock where Stock.Mat_Id=1
Now i have to write a condition to check whether all values are 1 else i have to terminate my loop.. How it can be done? any suggestions...
...
I'm trying to run the following query in SQLite 3:
SELECT *,
DISTANCE(latitude, longitude, ?, ?) AS "distance"
FROM "country"
WHERE "id" NOT LIKE ?
HAVING "distance" <= ?
ORDER BY "distance" ASC;
But I get the following error:
SQLSTATE[HY000]: General error: 1 a
GROUP BY clause is required before
HAVING
I don't understand ...
Hello all,
I have an interesting conundrum which I believe can be solved in purely SQL. I have tables similar to the following:
responses:
user_id | question_id | body
----------------------------
1 | 1 | Yes
2 | 1 | Yes
1 | 2 | Yes
2 | 2 | No
1 | 3 | No
2...
I have a database table with a column named featured which is used to highlight featured content on a page. Currently, I'm using two SQL statements to toggle the featured rows on/off like so:
-- Reset everything to non-featured
UPDATE tbl SET featured = '0';
-- Now set the selected rows as featured.
UPDATE tbl SET featured = '1' WHERE...
I want to think of a way to display and query comments.
Each comment can have children and siblings. I would like to display 40 comments in a page. However, I would like to show all the children. The problem here is if a child has more then 40 comments beneath it this will not work out. Also, I have no idea how I might get the comments....
I want to count many strings (>3G), so I choose SQLite with a table of (str TEXT PRIMARY KEY, count INTEGER DEFAULT 1).
There are about 3G strings, each takes 40*2/8=10 bytes, thus the whole strings is 30GB.
Of those 10 bytes, there are 2^80 kinds, which is much larger than 3G.
So how to update effectively ?
UPDATE table SET count = c...
This query method works :
SELECT xxx
FROM xxx-table
WHERE YEAR( CURRENT_DATE( ) ) - YEAR( '1988-10-27' )
- ( DATE_FORMAT( CURRENT_DATE( ) , '%m-%y' ) < '12-31' )
Between 20 and 25
But what I need is something like this...
SELECT YEAR( CURRENT_DATE( ) )
...
which method should one follow to drop master table if its primary key is referenced by a foriegn key in some other table?
i know about on delete cascade, is there any other way? which is the best practice
Thanks
...
how to do looping process inside stored procedure to insert max number of records
...
http://pastebin.com/m24c4f508
--any help would be appreciated
...
(SELECT SUM(CONVERT(FLOAT, CASE '01' WHEN '01' THEN CASE SIGN((sltr_tran_amt - ISNULL(sltr_matched_amt, 0))) WHEN 1 THEN CASE DBO.glas_aging_oth(CONVERT(DATETIME, '2009/04/04') - FLOOR(sltr_pstng_date)) WHEN 0 THEN (sltr_tran_amt - ISNULL(sltr_matched_amt, 0)) ELSE 0 END ...