Well, I try to use LIMIT clause in my subquery. It doesn't work with MySQL 5, and the error message states that: This version of MySQL doesn't yet support 'LIMIT & IN/ALL/ANY/SOME subquery'. Here is my first query:
SELECT * FROM user_activities WHERE DATE(activity_date)
IN (
SELECT
DISTINCT DATE(activity_date)
FROM user_activities
WHERE
user_id = 1069
ORDER BY
activity_date
DESC
LIMIT 3)
So, I ask my friend dara and a code from the Internet. His idea and that code is quite similar. The trick is to use a join statement. Make the subquery that use limit clause join with the original table. Here is my second code, it works:
SELECT ua.* FROM (SELECT DISTINCT DATE(activity_date) AS activity_date FROM user_activities WHERE user_id = 1069 ORDER BY activity_date DESC LIMIT 3) AS A INNER JOIN user_activities as ua ON DATE(ua.activity_date) = DATE(A.activity_date) WHERE ua.user_id = 1069 ORDER BY ua.activity_date DESC
Web 2.0, Ruby, Rails, TDD, BDD,
rSpec, XMPP, BOSH, REST,
Javascript, Ajax, Google Maps API,
Google Gears API, CSS,
Java, C#, Social Network, RMagick, Nginx
Friday, November 30, 2007
Thursday, November 22, 2007
Disable text selection on IE and FF
Last time, I posted a javascript function that disable text selection on IE and FF. This post doesn't need javascript to achieve this problem.
On FF, set -moz-user-select to none.
On IE, set attribute onselectstart to return false.
Here is an example:
On FF, set -moz-user-select to none.
On IE, set attribute onselectstart to return false.
Here is an example:
<div onselectstart="return false;" style="-moz-user-select: none;">
<p>Bibology for all.</p>
<p>All for Kibology.</p>
</div>
Labels:
javascript
Thursday, November 15, 2007
Fixing position: fixed on IE6
Maybe some of you realizes that IE6 doesn't support position: fixed because of its bug. Luckily, there is another bug works in a way that ALLOWS this to be done! Here is the solution besides using javascript to move the element when the user is scrolling:
1. First, put IE6 into "standards mode" by using a strict DOCTYPE.
2. Use IE conditional comments to style the HTML and BODY tags like so:
3. Style anything you want to stay fixed as position:absolute.
4. The only problem with this is that you cannot use absolute or relative positions on the moving page but float is allowed.
1. First, put IE6 into "standards mode" by using a strict DOCTYPE.
2. Use IE conditional comments to style the HTML and BODY tags like so:
html, body { height: 100%; overflow: auto; }
3. Style anything you want to stay fixed as position:absolute.
#menu {
position: fixed;
top: 100px;
left: 100px;
border: 1px solid #ccc;
}
* html #menu {
position: absolute; /* IE */
}
4. The only problem with this is that you cannot use absolute or relative positions on the moving page but float is allowed.
Labels:
css
Monday, November 12, 2007
jYMSG - Yahoo! Instant Messenger Library for Java
I just founded and tested a java library called jYMSG that provides a way for Java applications to connect and use the Yahoo Instant Messenger protocol, version 10 (YMSG-10) in a reasonably coder friendly and abstract way.
It is very nice. Here are serveral link about yahoo messenger protocol:
http://en.wikipedia.org/wiki/YMSG
http://jymsg9.sourceforge.net/
It is very nice. Here are serveral link about yahoo messenger protocol:
http://en.wikipedia.org/wiki/YMSG
http://jymsg9.sourceforge.net/
Labels:
news
Subscribe to:
Posts (Atom)