Hi
I'm writing a network server program in C++ which receives binary packets from network.
Packets are then stored in std::vector< unsigned char >
I've used MySQL 5.1 and MySQL Connector/C++ from ubuntu lucid to store packet information (field by field) into a table in a database. However, I also need to store the complete binary form ...
ORM tools are great when the queries we need are simple select or insert clauses.
But sometimes we may have to fall back to use raw SQL queries, because we may need to make queries so complex that simply using the ORM API can not give us an efficient and effective solution.
What do you do to deal with the difference between objects ret...
For a reservation system there is an inventory table and each item has a quantity (e.g. there are 20 chairs). Now the user can make a reservation for a specific period (e.g. 5 chairs for two hours "2010-11-23 15:00" - "2010-11-23 17:00"; another reservation could be for several days "2010-11-24 11:00" - "2010-11-26 14:00").
What's the b...
person(id, dogs)
how would I find the person with the most dogs
select *
from person p1
where p1.id in (
select p2.id
from person p2
where p1.id = p2.id
having count(dogs > (
select p3.id ...etc
am I on the right track or will this not work?
thanks for taking a look
...
I've got a table Employees with employees (say the important fields are ID int, Name varchar(50)) and a table Areas with sales areas (ID int, EmployeeID int, USState char(2)).
The sample values are:
Employees
ID Name
1 Shoeman
2 Smith
3 Johnson
Areas
ID EmployeeID USState
1 1 NY
2 1 ...
I was wondering,
What will be my motivation to use constraint as foreign key in MySQL, as I am sure that I can rule the types that are added?
Does it improve performance?
...
hi,
i am beginner with sql,
I have comments Template with button in the end of it to add the new comment to the database ,so i use SQL INSERT code to add and it works fine. but after button postback , the the new comment does not shows in my label until i refresh the page manually! .
this my code in c# code portion:
protected vo...
A)
select decode(count(*), 0, 'N', 'Y') rec_exists
from (select 'X'
from dual
where exists (select 'X'
from sales
where sales_type = 'Accessories'));
B)
select decode(count(*), 0, 'N', 'Y') rec_exists
from (select 'X'
from sales
where sales_type = 'Accessories');
C) ...
I am writing a nested MySQL query where a subquery returns more than one row and hence the query can't be executed.
Can anyone suggest me a solution for this problem.
Thanks in advance.
...
I'm building a small application and setting up foreign key relationships between tables. However I'm confused as to WHY I really need this? What is the advantage - does it assist me when writing my queries that I don't have to perform any joins? Here's an example snippet of my database:
+-------------------+
| USERS |
+----...
How to convert second select statement result to CSV String in main select statement ?
assume following SQL statement:
SELECT A1,A2, (SELECT aCol FROM Table2) as A3
FROM Table1
Now, I want to convert result of SELECT aCol FROM Table2 to CSV string that show at A3 field.
such as :
A1Value | A2Value | A3Value1, A3Value2, A3Value3
th...
Lets say I have a database with tables called box, item, and box_contents and I want to get any item that is contained in the box_content table (all items, but discard the ones that arent in the box_contents table). What would be the correct sqllite syntax for this?
...
Hey guys,
What is the best/most time efficient way to insert 1000 rows into one table (jdbc/connector-mysql database)? (it is a buffer and need to be dumped into the database everytime it is full)
1- One auto generated/concanated SQL statement?
2- for (int i = 0; i<1000; i++) { con.prepareStatement(s.get(i)); } con.commit();
3- stored...
If I have a table like this...
create table #words (
id int identity,
word varchar(1024)
)
insert into #words (word) values ('dock')
insert into #words (word) values ('dockable')
and i do a LIKE query
select id, word from #words where word like '%dock%'
Is there a way to tell which result would be the most accurate?
...
I have a system comprising 5 applications. Each app accesses a database via a DAL library. In the DAL i have an app.config with the following entry:
<connectionStrings>
<add name="DataAccessLayer.Properties.Settings.ConnectionString" connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=c:\users\something\something\MyDB.mdf;Inte...
How can I formulate a query for the below task:
Let's say you are logged in as user:1
I want to get one row per conversations I've had.
For each row I want to get, the
"Subject" of the first row within the conversation
"DateTime" of the first row
"Message" last message of this conversation no matter who wrote it
CREATE TABLE messages ...
I get that error when running the following query:
SELECT MAX( DateTime )
FROM (
(
SELECT DateTime
FROM Class_Searches
)
UNION ALL (
SELECT DateTime
FROM Book_Searches
)
)
WHERE User_Email = '[email protected]'
AND DateTime > NOW( ) - INTERVAL 30 DAY
I know I need to add Aliases but I'm not sure where
...
Hello :)
I have sqlite3 database with example structure and data:
CREATE TABLE person(id INTEGER PRIMARY KEY NOT NULL, name STRING NOT NULL);
INSERT INTO "person" VALUES(1,'Jack');
INSERT INTO "person" VALUES(2,'Daniel');
INSERT INTO "person" VALUES(3,'Sam');
INSERT INTO "person" VALUES(4,'T`lc');
CREATE TABLE vote(person_id INTEGER NO...
ID Level Effective Date ExpirationDate
000012-12 2 12/01/2005 NULL
000012-12 1 12/01/2005 NULL
000012-12 2 12/01/2005 01/01/2009
000012-A12 2 10/01/1994 11/30/2005
000012-A12 2 01/01/1999 11/30/2005
000012-A12 2 09/01/2001 11/30/2005
000012-A12 1 12/01/2005 12/31/2007
Only most current Records wil...
As most of you would know, when you save a view in MYSQL and then retrieve it later, it's all in native MYSQL, looks terrible - no line spaces, indents, plenty of UTF encoding tags littered around the place making your code look like sql soup.
Does anyone have a program or recommend a plugin to netbeans that i can use to format this sql...