|
I am migrating from ms access database to mysql database with java frontend so that my application can be used in linux as well .
in ms access here's what i would do go to create query . write a select statement . call give the name of the query as query...
Started by silverkid on
, 5 posts
by 5 people.
Answer Snippets (Read the full thread at stackoverflow):
You can
create view....
The query would look like
SELECT * FROM ( SELECT * FROM users ) query1;
You can either do nested of a query.
select * from table2 where user_id in (select user_id from users)
You can do this all in MySQL.
|
|
Hey, I'm making an e-shop and to display the tree of categories and all the products with their multiple variations of prices I made like more than 150 mysql_query("SELECT ..."); queries on one page. (If I count the "while" loops).
Is it too many, and...
Started by Mike on
, 4 posts
by 4 people.
Answer Snippets (Read the full thread at stackoverflow):
You don't want to hard code....
In this case you can select rows for all products in a single query, for example:
SELECT * FROM ceny WHERE produkt_id of ids is not hard coded.
It's usually a good idea to reduce the number of queries you run .
|
|
I have to perform a select on a table in the following manner: I am searching for some strings in 2 columns, the search string can be in either one or the second, or in both.
To select from a single column I would use something like:
SELECT * FROM table...
Answer Snippets (Read the full thread at stackoverflow):
Or depending on the exact semantics of your search:
SELECT.
OR both columns?
SELECT * FROM table WHERE col1 LIKE '%path1%' OR col2 LIKE '%path1%' OR col1 LIKE '%path2%' OR col2 LIKE '%path2%' OR etc.
|
Ask your Facebook Friends
|
I noticed something strange while executing a select from 2 tables:
SELECT * FROM table_1 WHERE id IN ( SELECT id_element FROM table_2 WHERE column_2=3103);
This query took approximatively 242 seconds.
But when I executed the subquery
SELECT id_element...
Started by True Soft on
, 3 posts
by 3 people.
Answer Snippets (Read the full thread at stackoverflow):
With an INNER JOIN, and see if that improves performance:
SELECT * FROM table_1 t1 INNER JOIN table_2 t2 around I have found is:
SELECT * FROM table_1 WHERE id IN ( SELECT id_element FROM (SELECT id_element.
|
|
The following MySQL query:
select `userID` as uID, (select `siteID` from `users` where `userID` = uID) as `sID`, from `actions` where `sID` in (select `siteID` from `sites` where `foo` = "bar") order by `timestamp` desc limit 100
…returns an error:
Unknown...
Started by Mathias Bynens on
, 6 posts
by 6 people.
Answer Snippets (Read the full thread at stackoverflow):
Try the following:
SELECT a.userID as uID ,u.siteID as sID FROM actions as a INNER JOIN users as u ON u.userID=a.userID WHERE u.siteID IN (SELECT siteID FROM sites WHERE foo = 'bar') ORDER the Select clause, and buiulds the first ....
|
|
Hi,
i have the following data in my table called cat_product
cat_id product_id 1 2 1 3 2 2 2 4
If given a set of values for product_id (2,3) i want to know the unique cat_id. In this case, that will be cat_id 1.
how should i construct mysql query?
i tried...
Answer Snippets (Read the full thread at stackoverflow):
SELECT * FROM (SELECT cat_id FROM cat_product WHERE product_id=2) a INNER....
select cat_id from cat_product where product_id in (2,3) group by cat_id having count(*) = 2
The number parameter bound to productsArray.length or similar.
|
|
Is there a straightforward way to run mysql_query with an insert and get the ID of the new row, for example in the return? Or will I have to do another query with select to check it?
Started by fmsf on
, 3 posts
by 3 people.
Answer Snippets (Read the full thread at stackoverflow):
Try mysql_insert.
Simply call mysql_insert_id after running mysql_query and you will get the ID.
|
|
Hello,
I am not sure if this is possible in mySQL. Here are my tables:-
Categories table - id - name - parent_id (which points to Categories.id)
I use the above table to map all the categories and sub-categories.
Products table - id - name - category_...
Started by Alec Smart on
, 8 posts
by 8 people.
Answer Snippets (Read the full thread at stackoverflow):
In a group, you use MySQL's FIND_IN_SET function, like so
SELECT p.ID FROM Products p INNER JOIN temp = cat; SET cat = SELECT CONCAT_WS(GROUP_CONCAT(id), cat) FROM Categories GROUP BY (parent_id) HAVING FIND_IN_SET(parent_id, cat); END ....
|
|
I have to get records from my MySQL DB where:
sentto = "$username"
OR
sentto = "everyone"
How would I put this in a MySQL query? I tried a few things, but they don't seem to be working:
mysql_query("SELECT * FROM pmessages WHERE status='unread' AND sentto...
Started by Chris B. on
, 5 posts
by 5 people.
Answer Snippets (Read the full thread at stackoverflow):
}
(or the mysqli equivalent)
The word OR is what you're looking for:
mysql_query to make sure that the....
This
if (@sentto is null) begin set @sendto='%' end mysql_query("SELECT * FROM pmessages WHERE;fetchrow()) { ...
|
|
How can I find out how many rows a MySQL query returns in Java?
Started by Midday on
, 4 posts
by 4 people.
Answer Snippets (Read the full thread at stackoverflow):
I don't think you can, except maybe by calling ResultSet.last .
In the SELECT clause.
|