is there any way to avoid using tmp table?
I am using a query with aggregate function (sum) to generate the sum of each product:
the result looks like this:
product_name | sum(qty)
product_1 | 100
product_2 | 200
product_5 | 300
now i want to join the above result to another table called products.
so that i will have ...
If I want to do a search on multiple columns for the keyword abc using like %abc%, how would I show some of the text around that keyword. Similar to what Google does with its search results.
...
Our application fetches the correct database server from a pool of database servers. So each query is really 2 queries, and they look like this:
Fetch the correct DB server
Execute the query
We do this so we can take DB servers online and offline as necessary, as well as for load-balancing.
But the first query seems like it could b...
Hello,
Say I have a string.
Then I have a number of unique tokens or keywords, potentially a large number in a database.
I want to search and find out which of these database strings are inside the string I provide (and get the IDs of them).
Is there a way of using a query to search the provided string or must it be taken to applicat...
I just checked out the licensing for SQL Server and well...i can't afford it since im funding this project myself. I have been tinkering with MySQL and PostgreSQL a bit the past few weeks and at this point I can't really decide which to go with. MySQL has a large user base and lots of people using it so finding out how to do various item...
Example:
Table: box
boxID color
01 red
02 blue
03 green
Table: boxHas
boxID has
01 apple
01 pear
01 grapes
01 banana
02 lime
02 apple
02 pear
03 chihuahua
03 nachos
03 baby crocodile
I want to query on the contents of each box, and return a table with each ID, colo...
I'm trying to write a report which will join a person, their work, and their hourly wage at the time of work. I cannot seem to figure out the best way to join the person's cost when the date is less than the date of the work.
Let's say a person cost $30 per hour at the start of the year then got a $10 raise o Feb 5 and another on Mar 1....
I have a table with a column called time, "HH:MM:SS". How can I do a batch update so that the value increment by 1 hour?
Is it something like:
update <table_name> set <time_column> = <time_column> + 3600 where ...
...
I am trying to do multiple counts everyone was working accept the first sub select (list1) I get an error that reads "Operand should contain 1 column(s)" i'm guessing it has something to do with the AND, but i'm not sure how I would fix this one.
Select Count(list0.ustatus) AS finished_count
, (Select list1.ustatus, Count(*) ...
I am working on a project that has a requirement such that login details can only be accessed from one machine at one time.
For example, if I grant you access to my website and you login from your home machine, the system will store this settings in a cookie/database. Now if you try the same login details on your work machine or any oth...
I am planning to make a web app which will eventually use Cassandra. But now that I don't have it and don't have server(s) to run it from, I'd like to start by using MySQL.
The question is, is it possible to structure data and queries in such a way that it would be fairly easy to later port it to Cassandra? Main idea, I guess, would be...
is there any way to avoid using tmp table?
I am using a query with aggregate function (sum) to generate the sum of each product: the result looks like this:
product_name | sum(qty)
product_1 | 100
product_2 | 200
product_5 | 300
now i want to join the above result to another table called products. so that i will have a s...
I am an old-school MySQL user and always preferred JOIN over sub-query. But nowadays everyone uses sub-query and I hate it, dunno why.
Though I've lack of theoretical knowledge to judge myself if there are any difference.
Well, I am curious if sub-query as good as join and there is no thing to worry about?
...
i am trying to create a foreign key in my table. But when i executes my query it shows me error 150.
Error Code : 1025
Error on create foreign key of '.\vts\#sql-6ec_1' to '.\vts\tblguardian' (errno: 150)
(0 ms taken)
My Queries are
Query to create a foreign Key
alter table `vts`.`tblguardian` add constraint `FK_tblguardian` FOREIG...
I have a column called "menu_order" which has no default value. When I select the contents of this column using the following select statement:
SELECT * FROM categories ORDER BY menu_order ASC
It lists the category items that have nothing as their menu order first and then the one's that have 1's and 2's and 3's. Is there any way to p...
I am trying to create a conversations based messaging system.
I want to group all messages that have the same conversation_id so that when I display a list of current conversations you only see the latest message from each conversation.
Can I group the values in the mysql query, or would I have to do it in the php?
...
Explain
SELECT `feed_objects`.*
FROM `feed_objects`
WHERE (`feed_objects`.feed_id IN
( 165,160,159,158,157,153,152,151,150,149,148,147,129,128,127,126,125,124,122,
121, 120,119,118,117,116,115,114,113,111,110)) ;
+----+-------------+--------------+------+---------------+------+---------+------+------+-------------+
| id | select_t...
here is the code
<?php
session_start();
if(!isset($_SESSION['user_name']))
{
header('Location: login.php');
}
$conn = mysql_connect("localhost", "root", "") or die("Can no connect to Database Server");
?>
<html>
<head>
</head>
<body>
<center>
<div id="ser">
<form action="" method="post">
<label for="file">Card No:</label>
<...
Hi
I've 2 mysql select statements, suppose these are my queries & their result :
Statement 1 :
select id from a
which returns this result set : { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }
Statement 2 :
select id from b
which returns this result set : { 3, 5, 10 }
I want to write a query which determines whether resultset1 contains a...
Hi everyone, forgive my newbie question, but why finding by '2' or '2' in Mysql returns the same record?
For example:
Say I have a record with string field named 'slug', and the value is '2'. And the following SQLs returns same record.
SELECT * From articles WHERE slug='2'
SELECT * From articles WHERE slug='2'
...