In a table containing cities I want to get the five biggest cities and order them by name:
SELECT * FROM cities ORDER BY population DESC LIMIT 5
That gets me the biggest cities ordered by population, but I want the same cities ordered by name. Is there an easy way to do this (without turning to a subquery or sorting the cities afterwar...
I'm trying to set a limitation for down sizing the browser window. I managed to resize to desirable size if resizing under this limit, but it only works in FF(not in IE and Chrome).
My questions are:
What's the best way for limiting resizing?
Why doesnt resizeTo does not work on Chrome and IE?
...
So I want to join two tables together, but for each row in the first table, I only want to join it to the top 8 matching rows in the other table, ordered by one of the columns in that table. Any clever syntax I can use, or do I need to get messy with subqueries?
...
I've been working with MYSQL for a few years now, and I often find myself wondering about this problem, but have never gotten around to researching it until now. So here goes. Let's say I have a table of authors, and a table of books. Each book has a field to link it to an author.
Now let's say I want to get an author and his books, all...
Here is current SQL:
http://www.copypastecode.com/22205/
It takes 70 new rows from table ads.
But it doesn't take proper amount(for example 5) of rows for each mr.region_id from joined table map_regions.
For example if I will add 50 ads in one region, it will take all 50 of them and leave 20 slots for the rest regions.
Please help me...
I am new to iphone development .I want parse an image url from a xml file and display it in a RSS feed.There are three image url but i want to retrieve only one url and display it.
<entry>
<id>xxxxx</id>
<title>xxx xxxx xxxx</title>
<content>xxxxxxxxxxx</content>
<media:group>
<media:thumbnail url="http://tiger.jpg"/>
<media:thumbnai...
Hi,
AppStore reject the online video application due to the bandwidth issue. So i want to check the current available bandwidth for the cellular network and run/download the online video. How can i do this? pl advice..
...
Say the users table in my MySQL DB contains a very large number of entries.
I need to go through all the users, but I want to do it only chunks at a time (i.e. using LIMIT and OFFSET):
SELECT * FROM users LIMIT 100 OFFSET 200
Is it possible to know the total number of users matched in the query, but only return a LIMIT number of them ...
I use Symfony 1.4 with Doctrine,
and I noticed that my project has similar issue with Jobeet project at index page (http://www.symfony-project.org/jobeet/1_4/Doctrine/en/06).
The problem is on index page the system shows to user jobs per category and we have 1+2*N database queries, where N - categories count.
This isn't very good, if ...
What do we mean by XPG6 in limits.h file?
...
<?php
if(isset($_POST['upload']))
{
//$albumid = $_POST['id'];
// Check to see if the type of file uploaded is a valid image type
function is_valid_type($file)
{
// This is an array that holds all the valid image MIME types
$valid_types = array("image/jpg", "image/jpeg", "image/bmp", "image/gif");
if...
I'm planning to design a class to limit the execution of a function to given amount within the specified time, for example:
Process max. 5 files in 1 second
It should be thread-safe and performance hit should be minimal.
How would you design such a class? I've got couple of ideas but none of them seemed right to me.
Is there any ...
Hello,
I have a list of 9 user id's and want to select 3 entries per user id.
My current query looks like this.
SELECT * FROM entries WHERE user_id IN (1,2,3,4,5,6,7,8,9) LIMIT 27
Some users have many more than 3 entries, so I want to limit the results of this query to 3 entries per user.
I tried making a UNION of 9 separate querie...
Is it possible to impose conditions on a SQL query to the greater of two conditions?
For example, imagine a site that has Posts. Is there a way to request posts such that the result will be guaranteed to contain both of at least all posts made in the past 24 hours, and at least 10 posts, but not unnecessarily exceeding either limit?
I...
I have a procedure SelectProc wich contains SELECT statement. I want to add a procedure param LimitRowsCount and use it as following:
CREATE PROCEDURE SelectProc (IN LimitRowsCount INTEGER UNSIGNED)
BEGIN
SELECT (...)
LIMIT LimitRowsCount;
END
but this approach doesn't work.
The SELECT itself contains nested subqueries so I ca...
Hello,
The problem is of a content website that is being scraped so badly that it breaks the server.
Is there an easy method of limiting access for IPs to a fixed number of requests at a time OR per day ? ( 10 pages / day or.... 10 pages every 2 minutes )
Ideally, I would keep a wildcard list for search engines and disallow everybod...
I've got quite a few SQL statements like such:
SELECT foo FROM things WHERE user_id IN (1,2,3..n)
Is there a known limit to the number of elements that will safely fit in an IN clause like that?
...
Hi, I'm trying to query a set of buldings listed on a table, these buildings are linked with tags. I'm able to do it, but my problem is how limit the number of tags to see:
table buildings
id building_name style
1 Pompidou bla
2 Alcatraz bla
3 etc. etc.
table tags // they can be 50 or m...
I have a schedule table I'm using jQuiry Sortable for editing.
Each day is a UL, and each event is an LI.
My jQuery is:
$("#colSun, #colMon, #colTue, #colWed, #colThu").sortable({
connectWith: '.timePieces',
items: 'li:not(.lith)'
}).disableSelection();
To make all LI's sortable except those with class "lit...
I have a table of events called event. For the purpose of this question it only has one field called date.
The following query returns me a number of events that are happening on each date for the next 14 days:
SELECT
DATE_FORMAT( ev.date, '%Y-%m-%d' ) as short_date,
count(*) as date_count
FROM event ev
WHERE ev.date >= NOW()
GR...