#mysql
22 October 2007
Total 24 pages. You are browsing page 2/24.
First :: Prev :: [1] [2] [3] [4] [5] [...] :: Next :: Last
02:36 <****> I've got the function, a dataset and the query I'm trying to run here: http://www.pastebin.ca/742114
02:38 <****> anyone ? - it makes no sense
02:39 <****> trym: what's the question?
02:39 <****> I have a table 'tasks' - which include fields 'ended_at' and 'user_id'. I want to return a list of 5 distinct user_id's sorted desc by ended_at. How do I accomplish this?
02:40 <****> with the queries one might expect to work.. the order is wrong - even though I include the order by ended_at desc
02:42 <****> SELECT user_id, ended_at FROM tasks WHERE blah GROUP BY user_id ORDER BY ended_at DESC
02:42 <****> Hello
02:43 <****> hey
02:43 <****> One question, is there a way to do an INSERT or UPDATE (if the row exists)?
02:43 <****> AzMoo[w]: the problem is thats giving the wrong results - I want to have the latest ended_at for each user_id
02:43 <****> the same effect as DELETE+INSERT but in atomic way
02:44 <****> max or min of ended_at
02:44 <****> whichever
02:44 <****> trym: it should be. What data type is ended_at?
02:44 <****> or what chadmaynard said.
02:45 <****> AzMoo[w]: datetime - let me paste some stuff
02:45 <****> I changed the object names a bit in an attempt to simplify - but you understand how it is by the paste
02:45 <****> http://pastebin.com/m3eb22cd7
02:45 <****> MISNI_: INSERT ... ON DUPLICATE KEY UPDATE <-- http://dev.mysql.com/doc/refman/5.0/en/insert.html
02:45 <****> I basically want to have it in the order of the first result there - but without duplicates
02:45 <****> of same task_id
02:46 <****> oh
02:46 <****> thanks AzMoo[w]!
02:46 <****> :***
02:47 <****> trym: you are using distinct when you should be grouping.
02:47 <****> ah.. am I?
02:48 <****> trym: when task_id = 34 which date do you want to be chosen ?
02:48 <****> trym: AKA ordered by
02:48 <****> the latest or the earliest?
02:48 <****> the latest date
02:49 <****> SELECT task_id, MAX(ended_at) AS ended_at FROM tasks GROUP BY task_id ORDER BY ended_at DESC LIMIT 5;
02:50 <****> brilliant :)
02:50 <****> thanks
02:50 <****> I understand the concept
02:51 <****> trym: if you want the comment, etc that go with that specific row it gets more compicated.
02:51 <****> ooh
02:51 <****> but fortunately I dont need it in this case
02:51 <****> good
02:52 <****> thanks again :)
02:52 <****> So, if I have the query: SELECT * FROM categories WHERE ISCHILDOF(categoryId, 122); <-- Am i correct when I assume that it will run that function on every categoryId in categories?
02:53 <****> AzMoo[w]: yes
02:54 <****> chadmaynard: right, thanks.
03:00 <****> Is there any way I can debug what's happening in a function? echoing or something? This is so confusing.
03:01 <****> what's wrong?
03:03 <****> chadmaynard: I've written this function which from what I can see, should be returning true or false in every instance, but it's failing with: No data - zero rows fetched, selected, or processed
03:03 <****> chadmaynard: http://www.pastebin.ca/742114
03:04 <****> what does select function(args that should return true); do?
03:06 <****> chadmaynard: SELECT ISCHILDOF(124, 122) <-- returns 1
03:06 <****> chadmaynard: SELECT ISCHILDOF(124, 0) <-- returns 1
03:06 <****> SELECT ISCHILDOF(122, 124) <-- returns 0, which is expected as 122 is not a child of 124.
03:07 <****> AzMoo[w]: that's odd. Can't you just join the tables anyway?
03:09 <****> chadmaynard: It's one table. has a categoryId, parentId, and description. I need to be able to select rows where the category is a child of another category.
03:10 <****> right.
03:11 <****> Is SELECT category_id AS children FROM categories t1 JOIN categories t2 ON (t1.parentId = t2.categoryId) right?
03:12 <****> chadmaynard: yes. You think I should use that in a sub-select?
03:12 <****> why?
03:12 <****> I mean if you have to
03:13 <****> you could possibly make the subselect a join too
03:13 <****> chadmaynard: Wait, no, it's not exactly right, sorry. You going to be around in about half an hour so I can explain it properly? I've got to go install a laptop for somebody, but then I'll be back.
03:13 <****> maybe, maybe not. Plenty of people can write self joins though.
03:14 <****> Ah well, not much choice anyway. I have to go now. Ta for the help.
03:34 <****> hi! how can i read the mysql*bin logs?
03:36 <****> ha?
03:39 <****> Can someone help me change my root pass
03:39 <****> xota: mysqlbinlog
03:40 <****> !man reset root password
03:40 <****> (How to Reset the Root Password) : http://dev.mysql.com/doc/mysql/en/resetting-permissions.html
03:40 <****> or just change it?
03:40 <****> in linux langauge please
03:40 <****> or change it
03:40 <****> but i dont know the original pass
03:40 <****> !man reset root password
03:40 <****> (How to Reset the Root Password) : http://dev.mysql.com/doc/mysql/en/resetting-permissions.html
03:40 <****> read
03:40 <****> thx chadmaynard
03:41 <****> can i see at all moment what is the sql querys?
03:41 <****> beacuse i'm programing on php and have errors
03:44 <****> chadmaynard would yo mind giving me the exact location of the unix comands to reset it
03:44 <****> cchance: I did. in that link
03:44 <****> I dont see it
03:44 <****> thats for windows
03:45 <****> scroll down
03:46 <****> is there some incredibly easy built-in method of checking when a table was last altered via a query ?
03:50 <****> ok i did the steps but its just hanging now
03:52 <****> my system hates mysqld
03:54 <****> theBear: SHOW TABLE STATUS
03:54 <****> Jonathon, your my hero for the day !
03:57 <****> cchance should have stuck around. hanging is the desired result.
03:57 <****> chadmaynard: are you going to the hanging?
04:03 <****> thoughtful: depends on you
04:04 <****> does it matter what order columns are in?
04:04 <****> Kupo24z: no
04:17 <****> SELECT l3.id, l3.namn FROM kategorier as l1 JOIN kategorier as l2 ON l2.id=l1.parent LEFT JOIN kategorier as l3 ON l3.parent=l2.id WHERE l1.id=1 OR l2.id=1
04:17 <****> I'm trying to select the siblings in the tree.
04:17 <****> of categories
04:17 <****> that works except it selects them twice. Would a subquery be more handy?
04:40 <****> I've done it better with distinct now
05:16 <****> flupps: thanks for bringing your site back on-line... I wanted that access_log slurp you gave us in training... got it.
05:21 <****> How do I select all the table fields from a table that's empty?
05:21 <****> it has names for columns
Total 24 pages. You are browsing page 2/24.
First :: Prev :: [1] [2] [3] [4] [5] [...] :: Next :: Last
