Given data that looks similar to this:
+---------+-----------+----------+
| country | city | district |
+---------+-----------+----------+
| Japan | Tokyo | 1 |
| Japan | Tokyo | 1 |
| Japan | Tokyo | 2 |
| China | Shanghai | A |
| China | Shanghai | A |
| China | Shangha...
Hi,
I have 2 tables one with a lot of records(table 1), and a second(table 2) with similar data but with far fewer records.
On a regular basis i need to add a marker to records in the larger table where there is a corresponding record in the smaller table. For example this could be an email address.
So if email address exists in the s...
I want to select patient_id and date difference from below table:
p_id TreatmentDate
15 2008-05-01
15 2008-05-03
15 2008-05-05
15 2008-05-07
16 2008-05-01
16 2008-05-03
16 2008-05-05
16 2008-05-09
16 2008-05-11
17 2008-05-03
17 2008-05-05
17 2008-05-07
I want to have this ...
So I have an input form that I want to use to update a table with certain fields of information. I have the ID of the record automatically coming up in a text box. I have three text boxes that I need to add to the table (excluding the ID) on a button click.
Name
Date
Method
are the field names.
As_Name
As_Date
As_Method
are the text ...
I have an SQL timestamp field and I need to group it by month like
Jan, Feb, Mar, ... but in numbers (01, 02, 03, ...)
I've tried
GROUP BY DATE_FORMAT(i.push_date, '%Y-%m')
But it's not working.
...
This way surely works,but it calls UNIX_TIMESTAMP 2 times:
mysql> select UNIX_TIMESTAMP(now()) - UNIX_TIMESTAMP('2009-09-23 22:07:42');
+---------------------------------------------------------------+
| UNIX_TIMESTAMP(now()) - UNIX_TIMESTAMP('2009-09-23 22:07:42') |
+---------------------------------------------------------------+
| ...
I have an Classic ASP page that lets users search for properties and a results page that then emails the property agents who have matching properties to let them know that there are tenants interested in their properties.
Some agents may have more than 1 property, in which case the agent only needs to receive 1 email rather than an emai...
I am designing a database using sql server express. Once completed how can I include sql server express and my database into the msi package to automatically install in the client's machine?
...
Hi,
I have a table that represents the parameters of a contract - including their change over time through addendums. The first addendum is a "special" addendum representing the parameters when the contract was first signed.
Here's how the table should look like:
ID ProjectID BeginDate DeadlineMonths DeadlineDate
1 20 20-12-2...
I was wondering if something like this was possible:
SELECT name or alt_name FROM users Where userid=somenum
I have also tried this:
SELECT name IF NOT NULL ELSE alt_name ...
If anyone has any insight I'd appreciate it.
...
I have a table that I would like to be able to present "ranked X out of Y" data for. In particular, I'd like to be able to present that data for an individual row in a relatively efficient way (i.e. without selecting every row in the table). The ranking itself is quite simple, it's a straight ORDER BY on a single column in the table.
Po...
Hi, is there a simple way to get the number of the current item in a simple SELECT? I need to deliver a column based on a calculation that involves the number of the current index in the select. I am simplifing my problem to an extreme, but roughly speaking, here is an example:
SELECT column1 * ITEMINDEX FROM table
I hope I am being c...
Hi All,
I found one question answered with Row_Number() function in where clause. When I tried one query, I was getting the following error.
"Msg 4108, Level 15, State 1, Line 1
Windowed functions can only appear in the SELECT or ORDER BY clauses."
Here is the query I tried. If somebody knows how to solve this, please let me know....
I'm working with survey data. Essentially, I want to count total responses for a question for a location, then use that total to create what percentage of all responses each particular response is. I then want to group results by location.
An ideal output would be similar to this:
Q1 | State | City | %
yes| MA | bos |10
no | MA ...
I'm learning SQL and I'm having trouble with a query.
I have the following tables:
[ laptop ]
price
model
[ pc ]
price
model
speed
[ printer ]
price
model
color
[ product ]
model
maker
How can I write a query that will return the model and price of any product which is made by maker "A"?
...
I should probably be able to find an answer to this but my Google-fu is weak today. When I have the same stored proc called multiple times by a web app, do the calls queue up or do they run independently?
...
Is there anyway invoke a PHP page / function when a record being inserted in to the mysql db table. We dont have control over the record insertion procedure.Is there some thing called trigger which can call a PHP script back ?
...
My employer has developed a utility that will run a stored procedure line by line against a DataTable, passing the fields of each row as parameters into the Stored Procedure. This is particularly useful for automated imports.
However, I now need to extend this to provide a transactional-ized version so that we can see the potential resu...
I'm programming a script using PHP and MySQL and I want to get a
unique id (consisting of a string: capitals and small
letters with numbers) like: gHYtUUi5b.
I found many functions in PHP that can generate such numbers but I'm afraid about how to ensure the id is unique!
UPDATE: uuid is long, I mean such id like: (P5Dc) an 11 alphanum...
When working with MySQL, how can I fetch all rows where the name column is all uppercase?
Since equality is case insensitive, I'm not quite sure how to do this.
...