is there any solution to show user all countries and after select country it reselect all cities of its country? be best with script selecting
p.s. russian name of countries
I've got 3 tables:
users (id, name, ...)
items (id, name, ...)
downloads (user_id, item_id, ...)
How do I get all users together with the number of downloads they have?
table1 has column CITY and COUNTRY. table2 has column CITY.
how do i delete from table2 all records that have CITY in common with table1 but also the COUNTRY='Russia' ??
please keep in mind that both tables have about 1 million rows of data
i have tables
profiles (id, name, deleted)
categories (id, name, deleted)
profiles_categories (id, profile_id, category_id, , deleted)
I have wrong query
SELECT p.id, p.name CONCAT_WS(', ', c.name) AS keywords_categories
FROM profiles p
LEFT JOIN profiles_categories pc ON p.id = pc.profile_id
LEFT JOIN categories c ON pc.id = c.id
WHERE p.deleted = FALSE
So, i want have result with all profiles with concan categories.name.
Thanks
i have a button and in the click event i have this code:
DoCmd.OpenReport "All_Ones"
when i click it, for some reason the report starts to print! why is this?
Would this using close this _connection?
using(SqlConnection _connection = Class1.GetSqlConnection())
{ //code inside the connection
}
//connection should be closed/ended?
I'm just wondering because GetSqlConnection() is a static function of Class1 and the whole connection might not be closed because it is calling outside class' static function instead of straight?
using(SqlConnection _connection = new SqlConnection(_connectionString)
{ //code inside the connection
}
I am working on a basic messaging system. This is to get all the messages and to make the row of the table that has an unread message Green. In the table, there is a column called 'msgread'. this is set to '0' by default. Therefore it should make any row with the msgread = 0 - green. this is only working for the first row of the table with the code i have - i verified that it is always getting a 0 value, however it only works the first time through in the while statement ..
require('./connect.php');
$getmessages = "SELECT * FROM messages WHERE toperson = '" . $userid . "'";
echo $getmessages;
$messages = mysql_query($getmessages);
if(mysql_num_rows($messages) != 0) {
$table = "<table><tr><th>From</th><th>Subject</th><th>Message</th></tr>";
while($results = mysql_fetch_array($messages)) {
if(strlen($results[message]) < 30){
$message = $results[message];
}
else {
$message = substr($results[message], 0 ,30) . "...";
}
if($results[msgread] == 0){
$table .= "<tr style='background:#9CFFB6'>";
$table .= "<td>" . $results[from] . "</td><td>" . $results[subject] . "</td><td><a href='viewmessage.php?id=" . $results[message_id] ."'>" . $message . "</a></td></tr>";
}
else {
$table .= "<tr>";
$table .= "<td>" . $results[from] . "</td><td>" . $results[subject] . "</td><td><a href='viewmessage.php?id=" . $results[message_id] ."'>" . $message . "</a></td></tr>";
}
}
echo $table ."</table>";
}
else {
echo "No Messages Found";
}
There's all the code, including grabbing the info from the database. Thanks.
Hello
I want to use XQuery on a column of data type NTEXT (I have no choice!). I have tried converting the column to XML using CONVERT but it gives the error:
Incorrect syntax near the keyword 'CONVERT'.
Here's the query
SELECT
y.item.value('@UserID', 'varchar(50)') AS UnitID,
y.item.value('@ListingID', 'varchar(100)') AS @ListingID
FROM
dbo.KB_XMod_Modules
CROSS APPLY
CONVERT(xml, instancedata).nodes('//instance') AS y(item)
(instancedata is my column)
Can anyone think of a work around for this ?
Thanks
I have a table which is with following kind of information
activity cost order date other information
10 1 100 --
20 2 100
10 1 100
30 4 100
40 4 100
20 2 100
40 4 100
20 2 100
10 1 101
10 1 101
20 1 101
My requirement is to get sum of all activities over a work order
ex: for order 100
1+2+4+4=11
1(for activity 10)
2(for activity 20)
4 (for activity 30) etc.
i tried with group by, its taking lot time for calculation. There are 1lakh plus records in warehouse. is there any possibility in efficient way.
SELECT SUM(MIN(cost))
FROM COST_WAREHOUSE a
WHERE order = 100
GROUP BY (order, ACTIVITY)
i am trying to connect to my local db using workbench but i do not see any way to connect. how do i do it? i already have this connection saved and succesfully tested.
Is there a simple way I can exclude nulls from affecting the avg? They appear to count as 0, which is not what I want. I simply don't want to take their average into account, yet here is the catch, I can't drop them from the result set, as that record has data on it that I do need.
i want to create a php with mysql to do the following:
lets say that i have a shop i want to rent, rent will be weekly or monthly. I'm searching for the best way to create this table, so i can do easy queries to calculate free weeks or months.
EDIT
let say i have
ID, START_DATE,RENING_TYPE,CLIENT_ID
where Start_date is the start date for renting, and RENTING_TYPE is weekly or monthly
how should i run a query to know all the empty weeks or month so new clients may reserve that week/month
for example a client reserve July month another client reserve the first week in June, if a new client logged in to my system and want to check all the available weeks/months, how can i achieve that ?
I want to join two tables on a UUID. table A's UUID is represented as varchar(32). table B's UUID is represented as binary(16).
what's the best way to join a varchar to a binary column?
I've tried using some sybase functions for this, but I'm getting different results and unsure of why:
select hextobigint('0x000036ca4c4c11d88b8dcd1344cdb512')
3948051912944290701
select convert(bigint,0x000036ca4c4c11d88b8dcd1344cdb512)
-2877434794219274240
what am I missing about convert and hextobigint? I must be misundstanding at least one of these functions. thanks for your help!
I have a parent table and child table where the columns that join them together are the UNIQUEIDENTIFIER type.
The child table has a clustered index on the column that joins it to the parent table (its PK, which is also clustered).
I have created a copy of both of these tables but changed the relationship columns to be INTs instead, have rebuilt the indexes so that they are essentially the same structure and can be queried in the same way.
When I query for a known 20 records from the parent table, pulling in all the related records from the child tables, I get identical query costs across both, i.e. 50/50 cost for the batches.
If this is true, then my giant project to change all of the tables like this appears to be pointless, other than speeding up inserts. Can anyone provide any light on the situation?
EDIT:
The question is not about which is more efficient, but why is the query execution plan showing both queries as having the same cost?
DoCmd.TransferText acImportDelim, Import-Accounts, "tableImport", _
"C:\Documents and Settings\accounts.txt", True
The second parameter: Import-Accounts is the actual name of the saved import specifications. supposedly it does NOT need to be in quotes; however in this case since there is a - there it is treating it as if i were doing an operation.
is there a way i can force it to treat it literally instead of as an operation?
I want to make a trigger that will prevent the insertion if the birthdate (one of the columns) is in the future. I have this:
CREATE TRIGGER foo
BEFORE INSERT ON table
FOR EACH ROW
BEGIN
IF NEW.birthdate > CURRENT_DATE()
THEN
???mystery???
END IF;
END;
What goes in the mystery part?
hi every one,
RDBMS: mysql
colonne names: Timefrom,timeuntill, timespent as the following
type of the colonnes:Time.
timefrom timeuntill timespent
10:00:00 12:00:00 02:00:00
08:00:00 09:00:00 01:00:00
how could i get the sum of the timespent.
like this example it would be 03:00:00.
when doing select sum(timespent) from mytable it display: 030000.
please help. thanks.
I have a table, links1, that has the columns headers CardID and AbilityID, that looks like this:
CardID | AbilityID
1001 | 1
1001 | 2
1001 | 3
1002 | 2
1002 | 3
1002 | 4
1003 | 3
1003 | 4
1003 | 5
What I want is to be able to return all the CardID that that have two specific AbilityID.
For example:
If I choose 1 and 2, it returns 1001.
If I choose 3 and 4, it returns 1002 and 1003.
Is it possible to do this with only one table, or will I need to create an identical table and do an INNER JOIN on those?
In the similar query Update on #temp table is faster then the @ table variable.
But I m forced to use table variable as I am wokring with function. I feel index is not being picked up for table variable. I have unique clustered index.
Please help
I want to build a query form my database depending my checkboxes list.
My checkboxes:
<input type="checkbox" id="searchName" checked> Name
<input type="checkbox" id="searchAddress"> Address
<input type="checkbox" id="searchCompany"> Company
<input type="checkbox" id="searchComments"> Comments
My PHP:
$subQuery='';
if($_POST['searchName']=='true') { $subQuery .= " AND KDX_Name LIKE :KDX_SearchTerm"; }
if($_POST['searchAddress']=='true') { $subQuery .= " OR KDX_PostalAddress LIKE :KDX_SearchTerm"; }
if($_POST['searchCompany']=='true') { $subQuery .= " OR KDX_Company LIKE :KDX_SearchTerm"; }
if($_POST['searchComments']=='true') { $subQuery .= " OR KDX_Comments LIKE :KDX_SearchTerm"; }
My problem:
If the first checkbox is not checked, my query is not working cause it works with OR whereas it must start with AND.
Could you please help ?
Thanks.
I need to add multiple records based on data from another table where the event is the same.
I've found on this forum
insert into table2(id,name)
select "001",first_name from table1 where table1.id="001"
as possible solution for my question.
So I thought this should be the following syntax:
insert into reservations(event,seat) select "99",id from seats where seats.id>0
to add all seats to event 99.
However when I run this query mysql gives the message 'MySQL returned an empty resultset (0 rows). (query 0.0028 sec)' and no records were added. I translated the message so could be sligthly different.
When I only use the "select "99",id from seats where seats.id0" query, it returns me 1080 rows.
I'm creating a members site, and I'm currently working on the user Preference settings. Should I create a table with all the preference fields (about 17 fields) or should I include them in the main member table along with the account settings?
Is there a limit as to how many fields I should have in a table? currently the member table has about 21 fields... not sure if its okay to add another 17 more fields when I can easily just put them in another table. It'll take more coding to pull up the data though... any sugguestions?
Hi ....
i have a problem in php code (inserting values in database)
i use PHPMyAdmin
my DATABASE has 3 tables:
1) Member with this fields: MemberID, MemberName
2) Room with this fields: RoomID, RoomName
3) Join with this fields: MemberID, RoomID
the idea is to join the member in the room.
My query was
mysql_query("INSERT INTO join (RoomID, MemberID)
VALUES ('121', '131')");
but unfortunately it is not work