I have a query which selects 6 names in the database. eg
SELECT names FROM users LIMIT 6
Now I want this query to select a random 6 names in the database table, is this possible? And how
for eg...
SELECT *
FROM ( SELECT RANK() OVER (ORDER BY stud_mark DESC) AS ranking,
stud_id,
stud_name,
stud_mark
FROM tbl_student ) AS foo
WHERE ranking = 10
Here foo is present...actually what it does ?..
I have 2 tables:
author with 3 millions of rows.
book with 20 miles rows.
.
So I have benchmarked this query with a join:
SELECT BENCHMARK(100000000, 'SELECT book.title, author.name
FROM `book` , `author` WHERE book.id = author.book_id ')
And this is the result:
Query took 0.7438 sec
ONLY 0.7438 seconds for 100 millions of query with a join ???
Do I make some mistakes or this is the right result ?
Do anyone know how to construct these two SQL statement in HQL;
SELECT MIN(id) FROM Books WHERE mid < ? OR mid =?
SELECT SUM(noOfBooks) FROM Bookcount WHERE mId=128
I have 300 boolean fields in one table, and im trying to do somithing like that:
One string field:
10000010000100100100100100010001
Ha a simple way to do a simple search os this field like:
select * from table where field xor "10000010000100100100000000010001"
Im tring this but is to long:
select * from teste where mid(info,2,1) and mid(info,3,1)
:) Help!!
In older versions of Windows, it was just open the Control Panel, select the System applet, select the Advanced tab, and then hit the Environment variables button. As a normal user, you could edit the "User variables" but not the "System variables".
In Windows Server 2008 R2, if I try to hit the Advanced System settings option in the System applet, it prompts for the Administrator password.
Hello All,
I dont know how to copy table data from
one server - database - table
TO
other sever - database - table.
If it is with in the same server and different databases, i have used the following
SELECT * INTO DB1..TBL1 FROM DB2..TBL1 (to copy with table structure and data)
INSERT INTO DB1..TBL1(F1, F2) SELECT F1, F2 FROM DB2..TBL1 (copy only data)
Now my question is copy the data from SERVER1 -- DB1-- TBL1 to SERVER2 -- DB2 --TBL2
Thanks in advance!
Is this equivalent to a LEFT JOIN?
SELECT DISTINCT a.name, b.name
FROM tableA a,
(SELECT DISTINCT name FROM tableB) as b
It seems as though there is no link between the two tables.
Is there an easier / more efficient way to write this?
This query generates an error because table2 doesn't exist:
Select * FROM table WHERE table2.id IS NOT NULL
Is there anything like this for check the table2 before apply the check on the id?
Select * FROM table WHERE (EXIST(table2) AND table2.id IS NOT NULL) or not EXIST(table2)
Thanks
I have 4 checkboxes added as a group so that I will be able to select only one checkbox.
But if I select one of them and now want to uncheck all of them in a group, I am unable to do that. Any one has idea how can I do that?
I've been looking into JOIN, subqueries and other ways of doing this, but I can't work out the best way to do this is...
I have a table (ps_category_product):
id_product, id_category
I want to perform a query on it like:
SELECT id_product FROM ps_category_product WHERE id_category='$this_cat'
BUT, I only want to perform this query where the ID's are returned by a query on another table (ps_product):
id_product, active
SELECT id_product FROM ps_product WHERE active='1'
Can anyone help me with getting these two queries working together?
Simple question I couldn't figure out (not a SQL expert... sorry): I want to do a select on the result set of sp_who2. How can I?
for ex. select SPID from [result set from sp_who2]
I know in asp.net 1.0 the grid display controls would pull all the data in, and then provide paging but the paging was done in memory.
Are there any smarter controls that provide paging where they only pull the data relevent to current page being displayed?
ie. select 10 rows for the current page, instead of doing a select of ALL the rows in the table.
Hi I have datatable having around 10 thousand rows.
I would like to store this data once for aspx page. When use select different options in page data would be further select from already stored datatable.
I then tried solution using ViewState, but as soon as data grow beyond 100 rows, performance degrade.
Where should i store data please help?
I have a table with products, their amount and their price. I need to select all entries where the average price per article is between a range.
My query so far:
SELECT productid,AVG(SUM(price)/SUM(amount)) AS avg FROM stock WHERE avg=$from AND avg<=$to GROUP BY productid
If do this, it tells me avg doesnt exist.
Also i obviously need to group by because the sum and average need to be per wine
I have problem querying table with variable in IN function.
SELECT
s.date,
(SELECT
GROUP_CONCAT(value)
FROM value
WHERE id_value
IN(s.ref_values)
)
AS vals
FROM stats s
ORDER BY s.date DESC
LIMIT 1
Where s.ref_values is '12,22,54,15'. I get only one return for first number (12).
When I insert that value directly in IN(12,22,54,15) it finds all 4.
So, there must be problem with using variable in IN. What am I doing wrong?
I have a SQL table it has more than 1000000 rows, and I need to select with the query as you can see below:
SELECT DISTINCT TOP (200) COUNT(1) AS COUNT, KEYWORD
FROM QUERIES WITH(NOLOCK)
WHERE KEYWORD LIKE '%Something%'
GROUP BY KEYWORD ORDER BY 'COUNT' DESC
Could you please tell me how can I optimize it to speed up the execution process? Thank you for useful answers.
for eg...
SELECT * FROM
( SELECT RANK() OVER (ORDER BY stud_mark DESC) AS ranking, stud_id, stud_name, stud_mark FROM tbl_student )
AS foo WHERE ranking = 10
Here foo is present...actually what it does ?..
I am working on localization project and when i change the language the UI gets disturbed because some translations are large. For example say there is button with text "Select All". But when this is localized in french it reads as "Sélectionner tout". That is larger than Select All and hence the gui gets affected. Is there any way to localize the gui as well.
I dont understand what is wrong with this query it is giving me compile time error of command not ended properly.The inner query is giving me 4 records can any body help me out.
select WGN3EVENTPARTICIPANT.EVENTUID
from
(Select WGN_V_ADDRESS_1.ADDRESSUID1 as add1,
WGN_V_ADDRESS_1.ADDRESSUID2 as add2
from WGN3USER inner join
WGN_V_ADDRESS_1 on WGN_V_ADDRESS_1.USERID=wgn3user.USERID
where WGN3USER.USERNAME='FIRMWIDE\khuraj'
) as ta
,WGN3EVENTPARTICIPANT
where (ta.ADDRESSUID1=WGN3EVENTPARTICIPANT.ADDRESSUID1) AND
(ta.ADDRESSUID2=WGN3EVENTPARTICIPANT.ADDRESSUID2)
I am running it in oracle.
Thanks
Amandeep
I have a large number of rows that I would like to copy, but I need to change one field.
I can select the rows that I want to copy:
select * from Table where Event_ID = "120"
Now I want to copy all those rows and create new rows while setting the Event_ID to 155. How can I accomplish this?
Hello,
We have observed that there seems to be a maximum number of ids/variables which one can pass in the IN clause of SQL as comma seperated values. To avoid this we are storing all the ids in a table and doing a SELECT within the IN clause. This however means extra database operations to store and retrieve ids. Is there any other way to use IN without SELECT?
regards
Sameer
for a table valued function in sql why cant we write sql statements inside begin and end tags like-
create function dbo.emptable()
returns Table
as
BEGIN --it throws an error
return (select id, name, salary from employee)
END
go
while in scalar valued function we can use these tags like
create function dbo.countemp()
returns int
as
begin
return (select count(*) from employee)
end
go
is there any specific rule where we should use BEGIN & END tags
I am using this code to check the checkbox is chekced or not..
$('#nextpage').click(function() {
var result = $('#Details input[type=checkbox]').attr('checked');
if (result == true) {
$("#tabs").tabs('enable', 3).tabs('select', 3);
}
else {
$().ShowDialog('please select atleast one');
}
});
using this I can check only for one checkbox
if I need to check for multipe checkboxes in teh Details page how do I need to loop throw?
thanks