limit

Ordering and limit

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...

trying to limit window resizing. how to do it?

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? ...

Limit the number of rows to join to, in mysql

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? ...

How do you limit compound records in MYSQL?

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...

How to limit by multiple categories(dynamically taken) in one SQL statement?

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...

how to limit parsing in iphone?

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"/&gt; <media:thumbnai...

Online video play bandwidth limit

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.. ...

SQL: Counting number of matching results when using a LIMIT query

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 ...

Symfony Jobeet: Need to refactor index page DB queries

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

What do we mean by XPG6 in limits.h file? ...

What should I add in order for this video to have a size limit

<?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...

Coding/Designing a generic thread-safe limiter (i.e. limit the execution of X() to Y many times per second)

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 ...

Looking for a way to limit SQL results 3 results per a specific column

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...

SQL or Ruby on Rails question: Limit results from a search to the greater of two conditions

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...

Limiting selected rows count with a stored procedure parameter in MySQL

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...

Impose access limits from Apache to prevent scraping ?

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...

In mysql or postgres, is there a limit to the size of an IN (1,2,n) statement?

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? ...

SELECT a list of elements and 5 tags for each one

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...

jQuery Sortable - Limit number of items in list.

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...

How to limit results by SUM

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...