|turbano||Chamelion -> join #php|
can i select an time between two fields?
these two fields are DATETIME
i search for that
|swampfox||Here's a query question: I'd like to know how to construct a query to get, say, 2 records before and after a given record. For example, if I have the id of 49, I'd like to get the two rows preceding it and the two rows following it. But the id numbers aren't necessarily contiguous. So they might be 47, 48, 49, 51, 54 or 42, 43, 49, 50, 61 . date field, but I thought it might be easier|
Ignore that last part, sorry. :)
Something like "SELECT [id AND ALSO 2 ROWS ON EITHER SIDE] from table where id=49;"
|spackest||not sure if I should ask here or in #ubuntu, but I can't get mysql reinstalled|
|turbano||ahm, try somethin like|
|swampfox||though I don't think "AND ALSO 2 ROWS ON EITHER SIDE" is valid SQL. :)|
|spackest||somewhere along the way, it got shutdown in a bad way, I think my innodb stuff corrupted and I can't get it started again|
|turbano||SELECT * FROM table WHERE id < 49 OR id > 51|
|spackest||I have tried wiping everything mysql I could find and doing an apt-get install mysql-server-5.0 and am having no luck|
also tried 5.1 with same results
|swampfox||turbano: No, I can do that once I know what the id is. But I have to construct the second query by hand. Here's what I'm doing.|
I have records that include the date they were entered (these are items in an inventory). When items leave, their records are deleted.
|spackest||it ends up stalled on Stopping MySQL database server: mysqld.|
and stalls on starting as well
|swampfox||So I have gaps in the remaining records, though I can order them by date.|
|spackest||I can telnet to 3306 and there's something listening there, but I can't connect|
|swampfox||I want a query that says "Return, as a single result set, 5 records sorted by date, where the middle one is id=3354" or whatever.|
I could do "Return 5 where the FIRST one is id=3354" using ORDER BY and LIMIT. But I don't know how to do one that puts the row I'm specifying in the middle of the result set.
turbano: Does that make more sense?
|turbano||ahm, i didn't get, you want to get the MIDDLE row?|
|swampfox||Basically, I want the SQL equivalent of grep's -C option, which shows not only the line you're searching for, but also a few context lines on either side of it.|
|swampfox||turbano: OK, right now I do this query: SELECT id, date_added FROM inventory where id=3354;|
|turbano||you want your query to return the specific result, and then returns two lines above, and two lines after?|
|turbano||hum, let me think|
|dim||Hi all.. I need to pull a list of all products from my DB.. problem is the products' info is scatted throughout 3 tables.. PRODUCTS table - products_id, products_quantity, products_model, products_image, products_price, manufacturers_id fields, and join them with PRODUCTS_DESCRIPTION table - products_id, products_alternate_name, products_name, products_description fields, and also with MANUFACTURERS table - manufacturers_id, manufacturers_name. Can|
|swampfox||As it is, it's pretty easy to do the two lines after it as a single query (SELECT id, date_added FROM inventory where id > 3354 ORDER by id ASC limit 2)|
|turbano||you could do something like where id > 3354 - 2|
but it could get bug
if you deleted the id 3353