In T-SQL, this is allowed:
DECLARE @SelectedValue int
SELECT @SelectedValue = MyIntField FROM MyTable WHERE MyPrimaryKeyField = 1
So, it's possible to get the value of a SELECT and stuff it in a variable (provided it's scalar, obviously).
If I put the same select logic in a stored procedure:
CREATE PROCEDURE GetMyInt
AS
SELECT MyInt...
Hello guys,
I want to make a database that will hold a date in it(SQLite).
Now first to ask is what is the right syntax to declare a date column.
The second i want to know is how to insert date in it after that.
And the third thing i want to know is how to select dates between, for example to select all rows which contain date between ...
I would like to take a database of say, 1000 users and select 20 random ones (ORDER BY rand(),LIMIT 20) then order the resulting set by the names. I came up with the following query which is not working like I hoped.
SELECT * FROM users WHERE 1 ORDER BY rand(), name ASC LIMIT 20
...
I have a form which includes select options with different items. Based on item selected, I need to show respective form on the same page.Does any one know jquery plugin for this or how aesthetically we can do this kind of requirement?
...
I need to know how many records were returned in a select in oracle. Currently, I do two queries:
SELECT COUNT(ITEM_ID) FROM MY_ITEMS;
SELECT * FROM MY_ITEMS;
I need to know the COUNT but I hate doing two queries. Is there a way to do:
SELECT * FROM MY_ITEMS
and then find out how many records are in there?
...
I have the following simple SQL statment
SELECT id, name, value_name, value_id
FROM table
GROUP BY id
ORDER BY value_id DESC
when grouping I would like to get the value_name and value_id of the tuple where the value_id is the biggest. The way it is i am getting the smallest value. For example
1, name1, valuename, 3 (where i know ...
I am not sure how to best describe what I am trying to do (or search for it for that matter) but I am going to try.
I have a pre-existing query (stored procedure) that returns items based on 3 specific ID's. What I want to do is to be able to reduce the results even further based upon a column within the results having the exact same st...
I have this table. I want to select back the items that don't exist already, so I can create them.
table tags
+---------+-------+
| tagId | name |
| 1 | C |
| 2 | DX |
| 3 | CG |
Say SQL looks like:
select name from tags where name in ( 'C', 'CG', 'RX' )
You get back 'C' and 'CG', so you know you h...
Consider a table,
Id columnA
1 a
2 b
3 c
Select ColumnA from table gives the result as below,
columnA
a
b
c
Is it possible to get
ColumnA
a,b,c
...
I have an SQL query which returns a set of data (around 40-50 tuples).
I would like to display the results 5 at a time on an HTML page using PHP.
I already managed to have the right SELECT statement, but i am having problems to display the results 5 by 5 using a "more" button.
Can you please help?
Note that every time i call the query,...
Hey all, I'm using select() to recv() messages from server, using TCP/IP. When I send() messages from the server, it returns a reasonable number of bytes, saying it's sent successful. And it does get to the client successfully when I use while loop to just recv(). Everything is fine and dandy.
while(1)
recv() // obviously pseudocode...
Below is my table
<table>
<tr class=chargeTR>
<td id=chargeTD>
charge1
</td>
</tr class=chargeTR>
<td id=chargeTD>
charge2
</td>
</tr>
<table>
Below is my jquery call
$(".chargeTR").each(function() { // this line works fine
$.get("process.php", {
...
select distinct * from Drivers where IsDeleted=0 gives me this,
I want select * based on distinct DriverMobNo column
...
How to list the departments in Oracle's EMP table which have either two clerks or three managers?
...
Hi,
I have an SQL listing shops, but i would like to random the results on a daily basis.
For example today I list bat 2, 6, 9 etc
and tomorrow, 6,1,7,9 etc
Is there a way to implement this?
...
select x from X x where x.a.id = :a_id --> Always 0 objects selected
Why does the above JPQL statement not work, but the one below work?
select a from A a where a.id = :a_id --> a_obj
select x from X x where x.a = :a_obj --> Always correct number of objects selected
Neither query throws an exception during execution, but a different n...
I have the following code:
<select>
<option value="0">Option 0</option>.
<option value="1">Option 1</option>
<option value="2">Option 2</option>
</select>
When you click on select I wish the first item to be no longer listed. Also it must work on all browsers. How can this be done?
Thanks.
...
I need an sql query to enumerate all views (I only need the view names) of a specific database in SQL Server 2005. Thanks in advance!
...
I have 3 tables: subcontracts, companies and contacts. Each table has a active_status flags which shows that the item is still active (hasn't been deleted).
Each contact has a company_id field which stores the id of the contact's company.
Each subcontract has a company_id field which stores the subcontract's company.
Each compan...
I have a database that I need to connect to and select from. I have an SQL Login, let's call it myusername. When I use the following, no SELECT permission shows up:
SELECT * FROM fn_my_permissions ('dbo.mytable', 'OBJECT')
GO
Several times I tried things like:
USE mydatabase
GO
GRANT SELECT TO myusername
GO
GRANT SELECT ON DATABASE...