Scenario
I need to build a table of data from a list of objects given a specification. In example, I have a list/array of Order objects, and a string specification detailing what the data table should contain e.g "ID;Date;Customer.ID;Customer.Name;Orderlines.Product.ID;Orderlines.Quantity;Orderlines.UnitPrice".
The order class class co...
I know there's got to be a way to do this, but for the life of me I can't figure it out:
I have 3 tables I want to join together (simplified to illustrate):
users
uid mail
1 [email protected]
2 [email protected]
3 [email protected]
profile_fields
fid name label
1 full_name Full Name
2 phone Phone
profile_values
uid fid value
1 1 ...
I have a lookup table say cities with fields CityId, CityName
CityId CityName
1 New York
2 San Francisco
3 Chicago
I have an orders table which has fields: CityId, CustId, CompletedOrders, PendingOrders
CityId CustId CompletedOrders PendingOrders
1 123 100 50
2 123 75 2...
Hi,
I don't want to use "not in" this sql query. How can I do it? thanks
SELECT
T2.Sno,
T2.Name,
T1.description,
T2.UserCode
FROM
Table1 AS T1 (nolock)
INNER JOIN T2 (nolock)
ON T1.UserCode = T2.UserCode
WHERE
g.xid= @p_xid
and T2.Sno not in (select Gid from T3 (nolock))
...
Hi,
I want to understand the process of nested join clauses in sql queries. Can you explain this example with pseudo codes? (What is the order of joining tables?)
FROM
table1 AS t1 (nolock)
INNER JOIN table2 AS t2 (nolock)
INNER JOIN table3 as t3 (nolock)
ON t2.id = t3.id
ON t1.mainId = t2.mainId
...
I have a query to subtract current balance from one table with previous balance from another history table. When a particular product has no current balance but has previous balance, I am able to subtract it correctly...in this case it will be like 0 - 100.
However, when the product has current balance but no previous balance, I am unab...
I have a series of related tables.
Transaction_Type
Transaction_ID (primary)
Transaction_amount
Transaction_Type
Transaction
Transaction_ID (primary)
Timestamp
Purchase
Transaction_ID
Item_ID
Purchase_ID (primary)
Item
Item_ID
Client_ID
I need to select transaction_type rows based on a time stamp and client_id
My query is as foll...
UPDATE HotelSourceMap
SET hsm.hotelid = co.hotelid
FROM HotelSourceMap AS hsm
JOIN hotels AS co
ON (hsm.hotelname= co.[name]
AND hsm.cityid = co.cityid)
its giving me error: The multi-part identifier "hsm.hotelid" could not be bound.
...
SELECT
description
FROM
diagnosis_mapping
LEFT JOIN
diagnosis_codes
ON
diagnosis_codes.codeid = diagnosis_mapping.codeid
SELECT
description
FROM
diagnosis_mapping
LEFT JOIN
diagnosis_codes
ON
diagnosis_codes.codeid = diagnosis_mapping.secondarycodeid
How to merge these 2 queries and get info in a s...
I would like to take the average of the time difference from Table1 below. The values are not consecutive and occasionally the time value is repeated, so I need to 1) sort by time, 2) discard non-unique values, 3) perform the time difference (in milliseconds), then 4) average the resulting time difference values. Further I'd like to 5)...
I apologize in advance for the non technincal description on this problem!
I have two tables: UsersOptions and OptionsList..
For simplicity sake, OptionsList is below:
ID - NAME
1 - Red
2 - Blue
3 - Orange
UsersOptions has many rows eg;
ID - CLIENT - OPTION
1 - John - Red
2 - John - Orange
3 - Mary - Red
4 - Jill - Blue
5 - Jill ...
A colleague asked me to explain how indexes (indices?) boost up performance; I tried to do so, but got confused myself.
I used the model below for explanation (an error/diagnostics logging database). It consists of three tables:
List of business systems, table "System" containing their names
List of different types of traces, table "Tr...
Hai guys,
I have two tables Incharge and property. My property table has three fields 1stIncharge,2ndIncharge and 3rdIncharge. InchargeId is set as foreign key for all the above fields in the property table..
How to write a select statement that joins both the table.. I ve tried a bit but no result
select P.Id,P.Name,P.1stIncharge,P....
Hi,
Is it possible to print out (PHP) all my blog posts + associated comments via one sql query?
If so, how?
I was thinking in this direction:
SELECT p.post_id, p.title, c.comment_body
FROM posts p
LEFT JOIN comments c
ON c.parent_id = p.post_id
But this didn't work out as I expected
...
I have tables & data like this:
venues table contains : id
+----+---------+
| id | name |
+----+---------+
| 1 | venue 1 |
| 2 | venue 2 |
---------------
event_dates : id, event_id, event_from_datetime, event_to_datetime, venue_id
+----+----------+---------------------+---------------------+----------+
| id | event_id | event_fr...
I want to join two tables in differenet databases on the same server.
Could someone tell me how I could do this in Zend Frameworks Db adapter?
...
I have a table filled with purchase prices, like this:
sku price btw startdate
PCR-CA5425023181515 21,17 € 1 01/01/2009
PCR-CA5425023181515 999,00 € 1 06/06/2009
PCR-CA5425023181515 444,00 € 4 09/07/2009
PCR-CA5425023181515 100,00 € 4 10/08/2009
I have another table filled with orders, ...
I have three tables, books, tags, and taggings (books-xref-tags):
books
id | title | author
1 | Blink | Malcolm Gladwell
2 | 1984 | George Orwell
taggings
book_id | tag_id
1 | 1
1 | 2
2 | 1
2 | 3
tags
id | name
1 | interesting
2 | nonfiction
3 | fiction
I'd like to ...
I have two mysql tables - a sales table:
+----------------+------------------------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+----------------+------------------------------+------+-----+---------+-------+
| StoreId | bigint(20) unsigned | NO ...
I have the following problem to solve:
Let's say there is a table A that contains an number of elements, this table is copied to become table B. In table B some of the original elements are lost and some are added. A reference table AB keeps track of these changes. Then table B is copied to be table C and again some of the existing elem...