I wanna do something like this:
insert into TableA
(val1,val2)
values
("value",(select top 1 tableB.X from tableB where tableB.Y=@Y))
I get this error:
Subqueries are not allowed in this context. Only scalar expressions are allowed
How to stop that error?
...
Which of these is better to use in regard to performance? ...in regard to readability / understandability? ...in regard to accepted standards?
SELECT *
FROM Wherever
WHERE Greeting IN ('hello', 'hi', 'hey')
OR
SELECT *
FROM Wherever
WHERE Greeting = 'hello'
OR Greeting = 'hi'
OR Greeting = 'hey'
The first seems more intuitiv...
I am using the Oracle system tables to get some metadata about the Packages in our database.
Here is one of my queries:
select AP.PROCEDURE_NAME
from ALL_PROCEDURES ap
where ap.object_name = :object_name
and ap.owner=:owner
and ap.procedure_name is not NULL
and ap.procedure_name like :procedure_name
I also want to find o...
I have an employee table, employee has interests, so the table can be designed like this:
create table emp(
id int(10) not null auto_increment,
name varchar(30),
interest varchar(50),
primary key(id)
);
or this:
create table emp(
id int(10) not null auto_increment,
name varchar(30),
interest enum('football','basketball','music...
I'm using Vertica Database. I am trying to get the total secs in a particular hour from the following example session data. Any sample SQL code would be very helpful - Thanks
start time end time session length(secs)
2010-02-21 20:30:00 2010-02-21 23:30:00 10800
2010-02-21 21:30:00 2010-02-21 22:...
So I have a form that has a listbox that shows like a ledger. My question is how can I make it display the last records (or have the scroll bar default to the bottom instead of the top), instead of the first few as the default.
Now I don't mean reversing the order from bottom to top instead of top to bottom (though that would be a cool ...
I have the most simple SQL
SELECT * FROM words
It has 13000 words (varchar). I need to get the longest word first in my output. I guess it might be possible with the WHERE command?
Alternative
If it doesn't work like that, is there a smart way to sort my output array so it will order it by the longest word first (in the 'word'-colum...
I am trying to create a report that has a summary for each group. For example:
ID NAME COUNT TOTAL TYPE
-------------------------------------------------------------
1 Test 1 10 A
2 Test 2 8 A
...
I new to MySQL. I would like to copy the content of one table to another table within the same database. Basically, I would like to insert to a table from another table. Is there easy way of doing this?
thanks for any help
...
I would like to begin work on an iPhone app that does little more than display a books content for reading. The book content is available online, and is fully open source, but I would like to make the content available locally. With apps that I have worked on previously, namely with iPhone OS 2.X, creating (or finding) an .sql database a...
My code so far is this. The last line gives me a compile error: "expected end of statement".
Dim strSql As String
Dim groupId As String
strSql = "Select ID from RevenueGroup where description = '" & ListO.Value & "'"
groupId = CurrentProject.Connection.Execute strSql
...
I am using SQL Server 2008's Full Text Search engine in my website. I have a search SP, which shows results sorted based on ranking.
I break up the search string and pass it to the FTS query engine like so (search string is 'test search':
("*test*" ~ "*search*") OR ("*test*" OR "*search*").
If the results row has the row 'test search...
I'm writing a script to check RSS feeds on regular intervals and need to prune out old articles. I came across this answer which seems really close to what I'm looking for: http://stackoverflow.com/questions/578867/sql-query-delete-all-records-from-the-table-except-latest-n
I need a similar solution that works the same way, except it k...
When writing a query for paging on a web page what is the least expensive method to get a total row count? Is there a way to do this without running a query twice - one for the total and the next for the limit?
Using MySQL
Example: (I want to know if there is a less expensive way)
Get Count
SELECT COUNT(*) FROM table
Get Paging
SE...
I am getting an error when I run this query because the data type money can't be implicitly converted to a varchar. However, I am using an if statemnt to make sure the data type is not money before I try the conversion. Clearly, the conversion is being executed anyways. Anyone know why?
table: BBH_NEW col: rebate2
datatype: money
if...
Starting in SQL 2005, VARCHAR(MAX) is no longer limited to 8000 bytes, it instead can go up to 2GB using "overflow" pages.
But what if I want to limit this column to say, 10k bytes? It seems I get an error if I try to put anything in the size parameter above 8000. Which is odd because MAX is the same as asking for a 2GB limit. Seems ...
I have a query that always returns one row, with many columns. I would like to turn this into 2 columns and many rows.
Original results:
Col1, Col2, Col3, Col4
----------------------
val1, val2, val3, val4
What I want:
ColName, Value
--------------
Col1, val1
Col2, val2
Col3, val3
Col4, val4
Is this possible?
EDIT ...
How do you find out the last time a MySQL database was read or written to?
Can you even do that check per table?
...
I'm trying using a TAdoTable component,
On form Create I call .Append() and in a button i call .Post()
but it loads the entire table! I don't need it to load anything, just need to insert a row into this table.
I was wondering if there is "good way" of inserting data into database with Ado, i already tried using the a "manual" appro...
There is a question here in stackoverflow with the same title but that is not what I am looking for.
I have a table like the one below
Name | Count
----------------
Chery | 257
Drew | 1500
Morgon | 13
Kath | 500
Kirk | 200
Matt | 76
I need to trasform this result set into something like this
Chery | Drew...