Complex Queries Versus Multiple Simple Queries
I am constructing a database to contain information about stories posted on my site. Information included will be things like title, author(s), genre(s), story codes, synopsis, etc.
I worked out that storing this information properly, so that it can all be searched on, could take as many as ten tables.
My question is this: Is a single complex query really better (more efficient for the server) than multiple simple queries? In other words, I may need the information for as many as 25 or even 50 stories for a single page.
Is it better to get all of the information out of a single, massive, complex query, or is it acceptable to get the information essentially one story at a time, which could mean 25 or 50 simple queries...?
View Complete Forum Thread with Replies
Related Forum Messages:
Complex Searching And Multiple Queries
I have a database of a list of companies and descriptions where users can login and see reports from companies they are subscribed to. 1) I want users to be able to search for a keyword and have it search the ENTIRE database for the keyword and return all rows. 2) For those returned rows, I want to cross-reference the permissions table and have it: ---A) return the company name and description if they are subscribed ---B) print that they are not subscribed to this company. Here is a simple version of the database: user ==================== id | username ==================== 1 | bob 2 | john reports ======================================= id | description | company ======================================= 1 | Green | Crayola 2 | Green | Bic 3 | Blue | Papermate permissions =========================== user_id | report_id =========================== 1 | 1 1 | 2 2 | 1 I need to put these two statements together(shown below). I need to have it search the DB and return all rows, then check to see if the person has access to that company. If they do, show it to them, if not print that a company was found but they are not subscribed to it. So if John was logged in and searched for "Green" his results would return two results, one would show that he could see the report from "Crayola" and it would also show that the company "Bic" was found, however he is not subscribed. Search results: 1) Crayola - click here to see the report 2) Bic - you are not subscribed to this company. Here is a look at the MySQL I have been trying to use: PHP $query1 = "SELECT * FROM `emt_report` WHERE `company` LIKE '%$P_search%' OR `description` LIKE '%$P_search%' OR `market1` LIKE '%$P_search%' OR `market2` LIKE '%$P_search%' OR `market3` LIKE '%$P_search%' OR `market4` LIKE '%$P_search%' OR `market5` LIKE '%$P_search%' OR `market6` LIKE '%$P_search%' OR `location` LIKE '%$P_search%' OR `date_year` LIKE '%$P_search%' OR `date_month` LIKE '%$P_search%' OR `source` LIKE '%$P_search%'" PHP $query2 = "SELECT u.id , u.username , p.user_id , p.report_id , r.id , r.company , r.description , r.market1 , r.market2 , r.market3 , r.market4 , r.market5 , r.market6 , r.location , r.date_year , r.date_month , r.source , r.video , r.audio , r.pp , r.execsum , r.report_url , r.exec_url FROM user as u INNER JOIN user_reports as p ON p.user_id = u.username INNER JOIN emt_report as r ON r.id = p.report_id WHERE u.username = '$username'" From above, how can i have search by query1 and then have it cross reference query2?
View Replies !
Long Queries VS Multiple Short Queries
I have a php script that requests a very long query from our mysql database. It has lots of joins and accesses at least 5-6 tables. My question is should i break it up into smaller separate queries or leave it as one long one, in regards to best practices?
View Replies !
Complex Queries On Many-to-Many Relationship
I'm building a system that involves performing fairly complex queries against a set of member data. The member data consists of answers to a series of questions, each question is multiple choice, with the possibility of the user selecting multiple answers to a question. As such, Answers to Member accounts is a many-to-many relationship. My table structure currently looks like this: (with extra, un-related fields removed) Code:
View Replies !
Combining Two Complex Queries
I'm dealing with hierarchical data using the modified adjacency list model. In implementing the ability to move entire subtrees, I've come up with the following two queries:
View Replies !
MySql Complex Queries With Joined Tables.
I am using MySql 5.0, I've created a database with few tables. Being a beginner I dont understand the joining syntax in MySql. I need help in quering and joining these tables. Configuring my Database: 1) How can I change a CurrentDate field with currentDate() or Date_Time() prebuild functions to show the current timestamp field? 2) Can I change the timestamp date format on the database? I am trying to add and retrieve the timestamp field on an ASP.NET application. Secondly, I need to query for the following scenarios: 1) List all rooms numbers with its Capacity, Room type and resource names; 2) List all reservations made for rooms on 'CreationDate' 3) When reserving a room on a start and end time, how can I query or check the database if the start and end time is not booked, ie in my asp.net application I need to check if there is no time conflict whilst booking a reservation of a room based on start time and end time. 4) List all reserved rooms on selection of current date with capacity and room numbers. 5) How can I lock a table when a booking transaction is being done simultaneously by another person? 6) Having inserted a userid and 'password' into mysql tables, is password a reserve word? How would I insert and retrieve forgotten passwords by email? 7) How can I create and call the above statements in stored procedures? This my Database: Code:
View Replies !
Complex Limit/offset Queries Causing Dirty Data
Thanks for reading. I have a rather complex page which is ultimately meant to return a list that's a small subset of products I sell. The page currently returns the list, but with an additional few items that should not be in the results. The code for the page works in 3 segments. 1st an sql statement links 2 tables (one table tells me the name of the product, and the other table tells me what genre I've decided the product falls in). The 1st statement counts the number of products which are not displayed on the final page, or finds the the offset value. It's an alphabetical list, so this 1st statement says, in effect, 'count everything from the start of the alphabet to the end of the letter c': PHP Code: ...........
View Replies !
2 Simple Mysql Queries
have problems with 2 simple queries and i dont know how to solve them. plz help me. first one looks like this: 1.What’s the average length of the movies released in 2006? And which movie comes closest to that average length? (search upwards) i wrote 2 separate queries: select avg(length) from film where release_year = 2006; and the second one: select title, length from film where release_year = 2006 order by length; i have to make this into one query. how do i do that? what should i write? the second query looks like this: One of the customers comes into the video store and he needs your help to find a children movie with 2 words to solve a word puzzle. In the puzzle the second word has 8 letters. He already knows that the 4th letter is “E” and the last 2 letters are “N” and “D”. Help him to find the movie i wrote: select title from film where title like ('% ___E__ND') and film_id in (select film_id from film_category where category_id in (select category_id from category where name = 'Children')); but the problem is that it doesnt return me a result. this query contains everything but the things are not in order. plz help me!
View Replies !
Slow Queries When Using Views Compare To Direct Table Queries
I’ve having problems with my server load for a while now. I have two tables with different content, but I need to display them in the same results, so I created a view with a union all (named: top_news_videos). The problem that I’m seeing is that when running a select to the view it takes a lot longer (and in that way, more server intensive) than running the query directly to one of the tables. For example, I created a page where I run 7 queries similar to this one: MySQL Code: ...
View Replies !
Many Smaller Queries Vs. Large Comlicated Queries
I am wondering if any one can help me. I have a page that will run around 85 smaller queries but if i combine the queries it will go down by almost half. This page is a high traffic page and I don't a complicated query taking up mysql resources while it created a temp table and such. My question is this: Is it better for mysql to run a lot of smaller queries (ex: simple selects with zero or one join, group by) or one larger complicated query with everything combined. The thing i have to keep in mind is that the mysql selects are comming off the localhost that the web server is also running on so they share the same resources.
View Replies !
Multiple Queries W/ 4.0.x (C API)
When executing multiple queries, which return a result set, must mysql_free_result be called after retrieving each result set using mysql_store_result? My concern is that if the result was not freed after each retrieval, that perphaps it may impose a memory leak. Or, does MySql reuse previously allocated memory for subsequent result sets? My app performs several back-to-back select and select/insert queries. Just need to know how to handle this action.
View Replies !
Multiple Queries
I want to make two queries with a single script, because I want to be able to output different results, in the event that there is no match for the first query, which searches for a variable passed from a select menu. But there is one option in the select menu that has no match in the db, so I want to return different results, which in this case, is all rows (All Models) for the given column (Models). I have gotten this to work, but it doesn't seem intuitive. I tried using the if and else clauses with the actual queries, but without success. Would someone be willing to show me the proper way of going about this--how to script it--but produce the same results. Code:
View Replies !
Multiple Queries?
well not really sure how to explain this one. I wrote a reate me script. One tha tallow syou to add a photo and leave comments for a photo. What I want to do is allow the admin to search thorugh all the comments. sure, easy query to just search comments, but I want them to be allow to search for a photo and grab the commetns on that specific photo. the photo table is linked to the comment table by photo.picid=comment.subjectid. I also want to grab the user info in this and that is linked to both tables really. but I could use the comment table like this, comment.postedby=user.id. now the photo names are the users id along with the date. so it would be like so 1_2006_10_25_1340.jpg so i thought I would let the user search for the user id and grab all photos with that id and load the comments as well. but I am following short. I get the photos, but no comments, or I get the comments but short on photos and the comments are the same comment for both photos. various mixed results The trick is that on the same search form I will allow them to search just comments, easy, or the date of the comment, or with the user so they can see all of the comments by said user. but getting the difference between all searchers is killing me cause I want to do only one query if I could. I don't think the table structure is important as you know th erelationship between the tables. but if you need it let me know. if any of this made sense what idea would you have for the query?
View Replies !
Perform Multiple Queries
I have created a file consisting of many create statements and I want to run this file for optimisation. I want the tables to be created at one time instead of going through them one by one on the command line shell. How can i do this is mysql. I know i can load data into pre-defined tables but how can i create tables using a file
View Replies !
Issuing Multiple Queries
My sql server is version 5.0.45. I am issuing multiple statements in phpmyadmin and they run just fine. The statements end with a semicolon. If I issue the same statements using php, I receive an error pointing at the first semicolon and the beginning of the second statement.Code: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '; UPDATE myreport SET q2pr2 = 'M' WHERE id = '66260' AND userid ' at line 1
View Replies !
MySql DB Multiple Queries
How well can a MySQL Database handle multiple queries, for example if I had 100 Queries at teh same time from multiple users to teh database, would it crash or anything? On a MySQL Server can host restrict how many queries a DB can receive? Because I'm planing on having "sometimes" multiple queries oen after the others, mayeb even 500 Queries at the same time for different things and different users.
View Replies !
Multiple INSERT Queries
I have a for loop that generates and submits a query on every itteration. The number of itterations can be can be anywhere between just a couple dozen and a few thousand. Is there a more efficient use of MySQL than this... PHP Code: for () { INSERT INTO... } There must be some way of building the query in the for loop and sending the entire thing out as just one query submission.
View Replies !
Using Joins Or Multiple Queries
I have two very large tables, with relational id's. Would it be faster to 1. use a join on the two tables? 2. make two queries If I were to make two queries would it be faster to use '...WHERE FIND_IN_SET(...' or to use '...WHERE IN(...'
View Replies !
Multiple Queries In One Shot
I'm actually using MySQL's C library/include files, so if this belongs in the C++ forum, my appologies, though it is somewhat of a newbie question. Anyhow, I'm trying to send more than one query with one call to the mysql_query() function. However, it seems that every time I attempt this, the query fails. I tried then to use phpmyadmin to manually insert the query, and lo and behold, it works flawlessly. So my question is, are you allowed to use the mysql_query() function to send multiple queries with just ONE call to the function? If not, what COULD be the problem? if(mysql_query(GameDatabase, "INSERT INTO skills(name, skill, percent) VALUES ('Galnor', '133', '99');" " INSERT INTO skills(name, skill, percent) VALUES ('Galnor', '138', '99');" )) Also, yes, before sending this query I was sure to empty the table, so that is not the problem.
View Replies !
Multiple Queries Within 1 Query
In the past, I have queried the database, grabbed one tidbit of information, then performed a second query to find the second tidbit, based on the information gathered from the first query. As you can probably guess, this method, although effective, is very slow. All of this comes from one table, in this case, named 'horse.' I thought that INNER JOIN was the way to solve this delimma, but my query causes errors. I am hoping someone can get me started down the right path. Here is my query: $result = mysql_query("SELECT p1.name,p1.dob,p1.color,p1.dam,p1.starts,p1.wins,p1.seconds,p1.thirds,p1.earnings,p1.mareFamily,p1.gender,p2.sire AS damSire FROM horse AS p1 WHERE sire='$prog_name' INNER JOIN horse AS p2 ON(p1.dam=p2.sire) ORDER BY p1.name ASC"); This cause the following error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'INNER JOIN horse AS p2 ON(p1.dam=p2.sire) ORDER BY p1.name ASC' at line 1 Warning: mysql_fetch_row(): supplied argument is not a valid MySQL result resource I am using MySQL 4.1.13-standard.
View Replies !
Avoiding Multiple Queries
I have a form that has 5 pull down menus that are identical that give all the results of a "categories" table (the user can choose up 5 categories to assign to the article). The form submits them as $_POST['cat1'], $_POST['cat2'] etc. where the values are the cat_id key value from the categories table. the next page is a preview that should show the corresponding cat_name value for each key submitted. Code:
View Replies !
Multiple Count Queries -> One Report
I'm getting a bunch of data out of a database in the form of a lot of COUNT statements eg: SELECT COUNT (*) AS "Value1" FROM tablename WHERE x=1; SELECT COUNT (*) AS "Value2" FROM tablename WHERE y=5; etc ... there are about 30 queries. I'm using PHPmyAdmin to do this. Currently I have to put each statement in separately: If I put the whole load of them, PHPadmin only displays the last value. I don't need a great deal of detail, but if someone can suggest a way I can accomplish this so I run one multi-line query and get all my values at once that would be great. Perhaps there is a better tool than phpMyadmin? Or maybe I should be looking at VIEWs or STORED PROCEDURES? If you can paint the broad outlines, I can fill in the gaps.
View Replies !
Merging Multiple SELECT Queries
I have two tables, one storing the info of the users ( one user in each record ) and the other the ids of several users in a single record i.e. (4,2,9,6), (4,2,8,3) etc. For convenience sake, i'll call it table1 and table2. What is need is to retrieve the records from table two and from the user ids, get all the users first name from table1. My problem is that i want to keep it within one query. I have tried looking up union and joins but they don't seem to meet my needs. What i would like to achieve is maybe (user1_first_name, user1, user2_first_name, user2 etc.) Is this possible at all?
View Replies !
Multiple Queries In One Recordset/connection
I am doing an insert, for which I want to get the auto-increment value back as a recordet in the same connection, I have the following: $query = ""; $query = $query . "INSERT INTO "; $query = $query . "myTable "; $query = $query . "(name,summary) VALUES "; $query = $query . "('" . urlencode($_POST["frmName"]) . "','" . urlencode($_POST["frmSummary"]) . )"; //echo "Query: " . $query; $result = mysql_query($query) or die('Query failed: ' . mysql_error()); I want to add to the query: $query = $query . "SELECT DISTINCT @@Identity AS 'newId' FROM myTable"; When trying a semicolan seperator, I get an error (this is also true in my query analyser - it doesn't work there either.) Is this even possible, and if so, what am I doing wrong?
View Replies !
Multiple Queries(checking A Value Against Many Tables)
I'm trying to develop a system where users sign up with user id's and PIN's. 1.I need to check if the PIN(pin) is valid(i.e exists in pins_table) 2.I need to check if the PIN has not been used(i.e does not exist in the members table) 3.I need to check if the chosen id has not been taken(i.e does not exist in the members table). Here is the portion of code I came up with to achieve this(after the initial ceremonies):
View Replies !
Multiple Stored Queries - From Access To Mysql
i have an access database queries, and i am trying to move them to mysql ... i have a stored query called "Rooms Available", and a stored query "Rooms Reserved" Rooms Available --------------- SELECT Rooms.RoomNum FROM Rooms LEFT JOIN [Rooms Reserved] ON Rooms.RoomNum=[Rooms Reserved].Room WHERE ((([Rooms Reserved].Room) Is Null)); Rooms Reserved -------------- PARAMETERS pDate1 DateTime, pDate2 DateTime; SELECT Booking.Room, Booking.Arrival, Booking.Checkout FROM Booking WHERE (((Booking.Arrival) Between [pDate1] And [pDate2]-1)) Or ((([Checkout]-1) Between [pDate1] And [pDate2])) Or (((Booking.Arrival)<[pDate1]) And (([Checkout]-1)>[pDate2]-1)); as you can see the "Rooms Available" query join the second one to get results .
View Replies !
How To Run Multiple Queries "simultaneously"
I'm in a position where I have to clean up an old database to make it compatible with some new data. Part of it entails going through each and every table and updating an "account ID", which has changed with the new data set. I'd written a simple code snippet to generate large chunks of SQL, like so: UPDATE myTable SET account_id = X WHERE account_id = Y; but then it dawned on me (and thank heavens it DID!) that this method won't necessarily work. e.g. if my query set had these two functions: UPDATE myTable SET account_id = 56 WHERE account_id = 100; UPDATE myTable SET account_id = 54 WHERE account_id = 56; The second UPDATE will update the rows previously set by the first query - and that I *don't* want. What I really need is to be able to execute an entire set of queries that act on the original database table content "simultaneously", so that the second query in my example will only update the rows that ORIGINALLY had an account ID of 54.
View Replies !
Multiple Tables Versus Mutiple Databases
In a setting of a web based application (typical LAMP installation) where multiple web users may be logging into the app and accessing data for one of numerous subgroups, each of which requires about 30 tables to run the application, which design will perform better: A) a single database with a set of identically structured tables for each subgroup differentiated by table name or B) a database for each subgroup, each with the same table scheme. In either case the two tables any individual web user will most commonly be accessing for their group have ten's of thousands of records, the remaining 28 or so required tables being much smaller (less than 100 records) and having group specific variables and data to control the application. In all cases the web application interface uses the same php code with the group identifier declared at login which selects either the table subset or group specific db. In case my question isn't clear scenario A would have a single database with a master table that controls the group numbers by an id, say 1 to 20 and then a set of 30 tables for each like (users_1, data_1, ...), (users_2, data_2, ...),...,(users_20, data_20,...). In this case the single database would have in excess of 600 tables. Scenario B would have a master database with a table to store individual group id's and each group id would have a database with a name based on their id like db_1, db_2,...db_20. Within any db_* there would be identically structured tables user, data, ... . In this case there would be 20 databases each with only 30 tables plus the master control db.
View Replies !
Multiple Complex Joins
How can one link two fields in one table to single field (Primary key) in another table in a single (left join) query, to return two values? e.g. Table 1 ID (PK) ...other fields Departure_ID Arrival_ID ...other fields "places" table Place_ID Placename (value to use in view) I think this is illegal but, more probably, impossible; perhaps someone could suggest an alternative methodology.
View Replies !
Complex - Extracting Data From Multiple Tables - Plz Help
I have spent more than 24 hours now just trying to build a query to extract data from multiple tables (which are a bit typical) in the format I need but in vain and I am goin MAD now . Any help would be really apprecaited. I have 5 tables: items, table1, table2, table3, and table4 table1, table2, table3, and table4 have got 368 columns each (366 representing each day of a year plus two additional columns - see below in structures) structures are as follows: items: ITEMID, TITLE, DESC ... table1: ITEMID P1JAN01, P1JAN02, ... P1JAN31, P1FEB01, P1FEB02, ...P1FEB29 ... P1DEC01, P1DEC02 ... P1DEC31, YEAR table2: ITEMID P2JAN01, P2JAN02, ... P2JAN31, P2FEB01, P2FEB02, ...P2FEB29 ... P2DEC01, P2DEC02 ... P2DEC31, YEAR table3: ITEMID P3JAN01, P3JAN02, ... P3JAN31, P3FEB01, P3FEB02, ...P3FEB29 ... P3DEC01, P3DEC02 ... P3DEC31, YEAR table4: ITEMID P4JAN01, P4JAN02, ... P4JAN31, P4FEB01, P4FEB02, ...P4FEB29 ... P4DEC01, P4DEC02 ... P4DEC31, YEAR Yes they are funny but that's the way they are. Note: Please note the month names within the column names Now I need to select SUM of a given month (say JAN) for a particular ITEMID from each of the tables for a given year (say 2006) for SUM i am using: PHP $p1 = "P1JAN01 + P1JAN02 + P1JAN03 + ... P1DEC31" $p2 = "P2JAN01 + P2JAN02 + P2JAN03 + ... P2DEC31" $p3 = "P3JAN01 + P3JAN02 + P3JAN03 + ... P3DEC31" $p4 = "P4JAN01 + P4JAN02 + P4JAN03 + ... P4DEC31" and then SELECT $p1, $p2, $p3, $p4 ... A basic query that I first tried was: PHP SELECT $p1 AS P1, $p2 AS P2, $p3 AS P3, $p4 AS P4 FROM items LEFT JOIN table1 on table1.ITEMID = items.ITEMID LEFT JOIN table2 on table2.ITEMID = items.ITEMID LEFT JOIN table3 on table3.ITEMID = items.ITEMID LEFT JOIN table4 on table4.ITEMID = items.ITEMID WHERE table1.YEAR = 2006 && table2.YEAR = 2006 && table3.YEAR = 2006 && table4.YEAR = 2006 This acts very funny...fetches me only the results which have got entries in all the tables. If there's no entry in any of the tables for a given item then that item is not fetched at all. The result set i need is something like this PHP ITEMID P1 P2 P3 P4 1 NULL 56 63 NULL 2 36 0 1253 63 3 NULL NULL NULL NULL and so on... and these all must be for a given year I tried playing around with the query with different joins and work arounds but no use. I really need this done soon. I'll be really thankful if you can suggest me anythig that can get me the result set i need. Please let me know if I am not clear anywhere.
View Replies !
How To Put These Two Queries Together?
Howto put these two queries together? sql = "SELECT DISTINCT medium_id, COUNT(tag) AS count FROM tags WHERE tag = 'test' GROUP BY medium_id ORDER BY count DESC" This query is working. Id like to try something like: sql = "SELECT * FROM media WHERE id IN (SELECT DISTINCT medium_id FROM tags WHERE tag = 'test')" But how can I order the resut by quantity (counts of tag)?
View Replies !
1 Or 2 Queries
I have an established schema of databases and tables. A requested feature came up, that would allow for a user to add an item to the database, and not have it display on the website. Would it be better for the site to run a query along the line of SELECT * FROM db.table WHERE item=item AND view='yes' or Get the data then run a query against a separate table to see if the part is in the not viewable database
View Replies !
2 Queries
it won't run both queries and unite them - it's ignoring 'where approved='yes')? : Code: $sql = "SELECT CONCAT(firstname , ' ' ,lastname) AS FullName, username, homepage FROM customer WHERE approved='yes' AND lastname LIKE 't%' OR username LIKE 't%' ORDER BY lastname ASC";
View Replies !
WHERE (xyz OR Abc) Queries?
I'm just wondering if it's possible to include some sort of "OR" type condition in MySQL queries? I'm assuming it can be done, but I can't seem to find anything, and of course typing MYSQL +"OR" into a search engine doesn't bring the most specific of answers.
View Replies !
2 SQL Queries
2 questions I'm hoping someone will be kind enough to help me with: Firstly, is it possible to do something like: SELECT * FROM (SELECT `table_name` FROM `table_list` WHERE `type` = 4 LIMIT 1); I'm trying to select the table name to use by querying another table. Secondly, I'm trying to use variables to tidy up another query: SELECT @r := TRIM(TRAILING '_' FROM `long_room`) AS 'Room' ... WHERE @r LIKE 'WL214'; Am I using variables in the right way? This doesn't return anything and using "'Room' LIKE 'WL214'" doesn't work. I know I can use the whole Trim statement in the Where clause, but I want a tidier way of doing it.
View Replies !
Max Queries
Using JDBC and a connection pool, MySQL 5.0 on Debian Sarge, does anyone have any prior knowledge or a suggestion - should I limit the number of queries per connection? If so - to what number? (I've already got a maximum time to live for a connection, so at any case I'm not going to reuse a connection forever). Is using and reusing a connection memory-consuming, tending to grow over time?
View Replies !
Best GUI For Queries
I currently use myqlcc instead of query browser, but have been looking for a replacement that might combine some of the best features of both (plus one still being updated). I use the prog for writing and running queries, not so much for administering the db. I don't hear a lot written about them, but these are what I consider to be the best features of mysqlcc, which I can't find replicated in other progs. Can anyone recommend a GUI that has at least some of them? --Table/field highlighting (recognizes real db data and highlights it when entered) --Autocomplete (shows me possible matches from partial entries with a keystroke) --Parentheses highlighting (lets me see what is in a given start/end parenthesis) --update/delete results messages (shows xx rows matched, yy rows affected) --Tabbed multi-threading (of course) --Ability to grab all/some results and copy to the clipboard for export to Excel (not all have this) Anytime I try to google favored applications, I come up with Navicat, which seems to have the budget to buy search results; doesn't make it a good program (does anyone like it?).
View Replies !
Queries Per Second: 135.73
According to Runtime Information: Queries per second: 135.73 Is this an acceptable value, or is this a sign that something is probably wrong? The site gets about 300k page views per day.
View Replies !
Two Queries At The Same Time?
I have 2 queries: The {..} are precalculated values. At the beginning no item can be matched by both where clauses. 1) update tabelle set L = L + {MOVE} set R = R + {MOVE} where L >= {LEFT} and R <= {RIGHT} 2) update tabelle set L = L - {DIFF} set R = R - {DIFF} where L >= {OTHERLEFT} and R <= {OTHERRIGHT} My problem: If I run update 1 first, the update 2 can match items from where clause 1 because the update changed the values from L and R so that they can be found at where clause 2. And if I run 2 first its the same in the other direction. So how can I do the 2 where clauses first, and when mysql knows my items I would like to update so no item gets updatet twice.
View Replies !
How To Log Specific Queries
I've got this DB. Every few minutes new data comes in and is inserted. Now and then for some reason duplicate data comes through - not a big problem - unique key. However I'd like to log the insert failures, due to dupes, but I don't want to log all of the good inserts also.
View Replies !
Join 2 Queries Into 1
I would like to know how to join 2 queries so that the results of these 2 queries show up in the same query: SELECT b.bios_serial_number FROM bios b: SELECT s.system_name FROM system s; Basically I want to create a report that includes both system name and serial number. I'm new to this and none of the JOIn documentation was clear to me.
View Replies !
IN Vs Individual Queries
If I needed to fetch 3 entries from a database, is there a significant performance difference between the following? SELECT * FROM JOBS WHERE myCol IN ('val1','val2',val3'); Versus SELECT * FROM JOBS WHERE myCol ='val1'; SELECT * FROM JOBS WHERE myCol ='val2'; SELECT * FROM JOBS WHERE myCol ='val3';
View Replies !
|