Menu
  • HOME
  • TAGS

MYSQL limit returns unexpected results

php,sql,limit

Your LIMIT use is wrong. Syntax: limit start_at, amount_of_records If you want 7 elements starting at 15th element, you should use SELECT * from products limit 14, 7 ...

MYSQL subquery needs to return multiple rows with LIMIT 5 per result from the parent query

mysql,subquery,limit

Figured it out. Hope this helps someone else. Feel free to add to it if it's inefficient. SET @rn = 0; SET @prev = 0; SELECT name, tot_yds, tot_tds FROM ( SELECT p.name, SUM(s.yds) AS tot_yds, SUM(s.tds) AS tot_tds FROM players AS p INNER JOIN ( SELECT s.id, s.player_id, s.yds,...

CodeIgniter Pagination for two different database results

php,codeigniter,pagination,limit,offset

So, this is the solution to my problem. I wanted two sets of results to be in one view. I want 20 records to be displayed in one page. So, $config['per_page'] = 20 If the user wants just the list of courses, only one query runs, else two query results...

How to overcome the browser limit for cookies?

jquery,cookies,browser,datatable,limit

Datatables uses localStorage and sessionStorage by default, so unless you have to support an older browser like ie 6/7, then you should not worry about running into cookie limitations. https://datatables.net/examples/basic_init/state_save.html Used in conjunction with stateDuration set to 0, your state will be stored indefinitely. https://datatables.net/reference/option/stateDuration That being said, if you...

How can I limit a generic data structure to allow only elements of a specific interface?

java,generics,interface,limit

You can introduce an upper bound on your type parameter E. interface GenericSortedList<E extends Comparable<E>> extends Iterable<E> Also make sure you pass E as the type parameter to Iterable, or else it will extend the raw form of the Iterable interface. To make it more flexible, you can put a...

hibernate 4.2.5 + mssql 2008 + like + setmaxresults = fail

sql-server,hibernate,limit

After a lot of research, I found out that Hibernate + MSSQL have a problem regarding using JPA Queries with setFirstResult(int) and setMaxResults(int). The solution was to use a NativeQuery. Example: StringBuffer sql = new StringBuffer() .append("WITH PAGINATEDQUERY AS ( ") .append(" SELECT Q.*, ROW_NUMBER() OVER (ORDER BY CURRENT_TIMESTAMP) as...

java regular expression examples for match without length limitation

java,regex,expression,limit

G - the letter G [0-9] - a digit .* - any sequence of characters So the expression G[0-9].* will match a letter G followed by a digit followed by any sequence of characters....

Check if SELECT statement with LIMIT returned all rows

mysql,select,limit,rows

This is too long for a comment. You can use SQL_CALC_FOUND_ROWS and FOUND_ROWS: $sql= "SELECT SQL_CALC_FOUND_ROWS * FROM tbl_group_message WHERE gid = ".$gid." ORDER BY mid DESC LIMIT ".$more." ORDER BY mid ASC"; Then run the query SELECT FOUND_ROWS() as the next query to the database. More information is in...

Limit the amount of times font size can be increased and decreased

javascript,jquery,ruby-on-rails,limit,font-size

After adapting the answer provided by @Andrei Nikolaenko, adding this into my application.js worked: var minSize = 1; var maxSize = 1.5; function resizeText(multiplier) { var elem = document.getElementById("sizeable"); var currentSize = elem.style.fontSize || 1; var newSize = parseFloat(currentSize) + multiplier * 0.2; if (newSize < minSize) newSize = minSize;...

MySQL: WHERE IN() limited to one row peer argument

mysql,sql,limit,where-in

http://sqlfiddle.com/#!9/6412b/2 SELECT `table1`.* FROM `table1` LEFT JOIN `table1` t ON `table1`.reference_id = t.reference_id AND `table1`.id<t.id WHERE `table1`.reference_id IN(2,3) AND t.id IS NULL GROUP BY `table1`.reference_id ...

Limitations of the mod % operator with big integers

c++,limit,modular-arithmetic

Some time ago i used GMP library, maybe it will help you too. https://gmplib.org/ This should be a comment but can`t make one yet....

Create a DBF field with more than 254 of width from C#

c#,width,field,limit,dbf

It is failing on your column of 400 characters... dbase/vfp tables only allow 255 characters for a column width.. After that, you have to use a "memo" field which is free-form and can hold text or binary. The only other possibility that I can think of looking into is SyBase's...

Amount of local memory per CUDA thread

memory,cuda,limit,local

It seems you are running into not a local memory limitation but a stack size limitation: ptxas info : Function properties for _Z19kernel_test_privatePc 65000 bytes stack frame, 0 bytes spill stores, 0 bytes spill loads The variable that you had intended to be local is on the (GPU thread) stack,...

How to merge two sql queries into one with variable limit

php,mysql,limit

to expand slightly on dirluca's fine work create table product ( id int not null auto_increment primary key, -- as per op question and assumption title varchar(255) not null, bought int not null -- bought count assumption, denormalized but who cares for now ); create table user_favourites ( id int...

Mathematica 2D limit computation

wolfram-mathematica,limit,wolframalpha

Limits of a function f along path p depends on which path is taken. You hint at this in the question. If we insert y=x^3 into f, we get the constant 1/2. So the limit of f towards (0,0) along the path y=x^3 is 1/2. Mathematica only computes limits along...

How can I set max word count?

count,set,word,limit,sphinx

There is no setting for this. And even is was doubt it wold inprove performance. When doing the counting loop, would have to add a conditional, to check if above a threshold and if so do nothing, otherwise increment the counter. its less work to just to increment anyway. Max_matches...

Limit a set of processes' CPU and memory usage

linux,osx,process,resources,limit

Will the program launched from this console inherit the niceness of the console itself? The answer is yes. You can check it nice -n19 xterm. In the console, start someprocess, then check the nice level using ps -efl | grep someprocess. The nice level is inherited....

Limit row a table in SQL and Insert new rows on Top

sql,table,insert,limit,rows

You can't really limit a table for a fix number of records but you can get rid of unwanted records. Assuming you are on SQL-Server --STEP1 :Do your insert here --STEP2: Delete older records over 200 ordering by dateTime column ;WITH CTE AS ( SELECT *, ROW_NUMBER() OVER (ORDER BY...

How do I limit the amount of letters in a string

python,string,variables,limit

Python's input function cannot do this directly; but you can truncate the returned string, or repeat until the result is short enough. # method 1 answer = input("What's up, doc? ")[:10] # no more than 10 characters # method 2 while True: answer = input("What's up, doc? ") if len(answer)...

Error in MySQL Query with multiple joins and limit on first table

mysql,sql,left-join,limit

Fixed it thanks to @Ravinder his comment about missing the on clause updated sql: SELECT a.alerts, a.title, a.lat, a.lon, a.alert_content_id, a.date_added, r.countRep, i.countInt, ac.img, c.marker, c.subcatvan FROM (SELECT alerts, title, lat, lon, alert_content_id, date_added, cat FROM `alerts` LIMIT 10) a LEFT JOIN (SELECT alert_id,count(DISTINCT id) as countRep FROM `reply`) r...

SELECT 3 comments for each post [duplicate]

php,mysql,sql,group-by,limit

it is like doing partition based on post_id and then doing selection of 3 elements in that partition you can achieve this using mysql variables select id, comment, post_id from ( SELECT id, comment, post_id, @row_number:=CASE WHEN @post_id=post_id THEN @row_number+1 ELSE 1 END AS row_number, @post_id:=post_id AS varval FROM comments...

Is there an equivalent MYSQL “LIMIT” Clause in SQL Server? [duplicate]

sql,sql-server,limit

In MSSQL you need to use FETCH-OFFSET <offset_fetch> ::= { OFFSET { integer_constant | offset_row_count_expression } { ROW | ROWS } [ FETCH { FIRST | NEXT } {integer_constant | fetch_row_count_expression } { ROW | ROWS } ONLY ] } From MSDN OFFSET { integer_constant | offset_row_count_expression } { ROW...

Limit slows down my postgres query

postgresql,limit

The planner is expecting 45438 rows for username '1228321f131084766f3b0c6e40bc5edc41d4677e', while in reality there are only 2131 rows with it, thus it thinks it will find the 10 rows you want faster by looking backward through the interval_time index. Try increasing the stats on the username column and see whether the...

using sql LIMIT 1 on specific queries

php,mysql,sql,pdo,limit

It could make a big difference if you do not have an index. Consider the following with no index: select * from clients where client_id = x The engine will need to scan the entire table to determine that there is only one row. With limit 1 it could stop...

Limit length of ListField in mongoengine

python,mongodb,limit,mongoengine,listfield

There is nothing like this built into the ListField, but you can make your custom ListField providing a max_length attribute: class MyListField(ListField): def __init__(self, max_length=None, **kwargs): self.max_length = max_length super(MyListField, self).__init__(**kwargs) def validate(self, value): super(MyListField, self).validate(value) if self.max_length is not None and len(value) > self.max_length: self.error('Too many items in the...

Limit sum of rows in MySQL

mysql,sum,limit,rows

You could try creating a running total variable, like this: SET @runtot:=0; SELECT p_id, p_description, (@runtot := @runtot + p_quantity) AS runningTotal FROM product_table WHERE @runtot + p_quantity <= 21000 AND p_reference = '1A00001'; Here is the SQL Fiddle. This will only return the first rows found that fulfill this,...

SQL limit SELECT but not JOIN

mysql,sql,select,join,limit

I would write a subquery to get the three first products (or whatever condition you choose) like this: SELECT id FROM product ORDER BY id LIMIT 3; Once I have that, I can select everything from the price table as long as the id is in that subquery. You can...

How would I limit upload and download speed from the server in golang?

file-upload,go,download,limit

There's a token bucket algorithm that can be helpful to implement such the rate limit. I found an example implementation, which you can use: https://github.com/juju/ratelimit package main import ( "bytes" "fmt" "io" "time" "github.com/juju/ratelimit" ) func main() { // Source holding 1MB src := bytes.NewReader(make([]byte, 1024*1024)) // Destination dst :=...

overcome 32k limit when inserting oracle clob IN parameter using spring StoredProcedure

spring,oracle,stored-procedures,limit,clob

PL/SQL has a hard limit of 32k chars if you send the data as a character string. If the parameter is a CLOB you can first create a temp LOB, fill it up with data and then call your PL/SQL procedure with the CLOB object.

Limit CPU & Memory for *nix Process

unix,limit,quote

If you happen to use Solaris, the ability to limit resource usage is a native feature. Memory (RAM) usage can be capped per process using the rcap.max-rss setting while CPU usage can be limited per project using the project.cpu-caps. Note that Solaris also allows OS level virtualization (a.k.a. zones) which...

How to average last amount of last 5 transactions

mysql,limit

You can do this by enumerating the rows usig variables: SELECT avg(amount) as price, p.product_name, p.producer FROM (SELECT t.*, (@rn := if(@p = t.Product_Id, @rn + 1, if(@pr := t.Product_Id, 1, 1) ) ) as seqnum FROM wp_transactions t CROSS JOIN (SELECT @rn := 0, @p := 0) vars WHERE...

How would ylim be automatic from data for a given xlim in matplotlib?

matplotlib,limit,axis

Use the min and max values for that range: >>> data = np.random.random((1000,)) >>> data.shape (1000,) >>> plt.plot(data) [<matplotlib.lines.Line2D object at 0x37b7f50>] >>> plt.ion() >>> plt.show() >>> plt.xlim(450,470) >>> plt.ylim(np.min(data[450:470+1]), np.max(data[450:470+1])) Or to use a function doing both: def plot_autolimit(x, y=None, limit=None): if y is None: plt.plot(x) else: plt.plot(x, y)...

Selecting from two tables, limiting by the first

mysql,table,limit

I got what I wanted with, SELECT * FROM ( SELECT date AS date FROM entries ORDER BY date DESC LIMIT 4 ) AS ent, link WHERE ent.date = link.date This gives me entries and all their tags, and limits to four entries, without cutting the tags off. It outputs...

MySQL Limit Offset Difference

mysql,select,limit

There is no difference. If you leave the offset parameter, it will be 0 by default....

How can I limit PHP code to a specific folder? [closed]

php,folder,limit

Marc B suggested a chroot jail - but like VPS, this effectively entails running at least seperate FPM pools for each student. A simpler solution would be to use the open_basedir functionality to constrain scripts to their own directory tree. You can enable this in the webserver config on a...

Emberjs not returning all records

mongodb,ember.js,sails.js,limit,resultset

Explanation That's because the default response limit in Sails is 30 records. It's there obviously so that if you have 10k or a million rows you don't make some normal request and accidentally dump out your entire database to the client and crash everything. This is documented here: http://sailsjs.org/documentation/reference/configuration/sails-config-blueprints defaultLimit...

Pagination Hibernate JPA: orderBy + setFirstResult + setMaxResult

mysql,hibernate,jpa,order,limit

Maybe a problem with the view technology? Did you run Sysout resultList to confirm that sort order problem is from JPA? When you change to second page, the filters still there?

How to limit the choice in django

python,django,forms,limit

You have two options: You can show a drop down with one country. You can not show the country at all, and set it in the view before you save the object. For option 1: class AddCountryForm(forms.ModelForm): country = forms.ChoiceField(choices=(('RUS', 'Russia'),)) class Meta: model = Country fields = ('name_of_team',) For...

Manage with limit and offset in php

php,limit,offset,musicbrainz

The pseudo code answer from Jordumus is correct, but this is how you have to modify your code to make it work. $limit = 100; $offset = 0; $release_count = 0; $includes = array('labels', 'recordings'); do { if ($offset != 0) sleep(1); try { $details = $brainz->browseRelease('artist', '302bd7b9-d012-4360-897a-93b00c855680', $includes, $limit,...

Shopify Product Replacement Parts

api,limit,shopify,product

Ok so I have a couple different answers to this question. Not sure which one I will use yet. Method 1: Filter Collection by Tag using URL The first one was provided by Shawn Rudolph on the Shopify forums. It involves filtering a collection by tag using the URL. Shawn's...

MySQL select top rows with same condition values

mysql,sql,select,sql-order-by,limit

This is the right solution, I think: you need the subquery to know how much post has the 10th place in your top ten. Then, you use the outer query to extract the users with almost that postcount. SELECT u.username, COUNT(p.id) AS count FROM Posts p JOIN Users u ON...

Limit results on 2 decimal

javascript,jquery,decimal,limit

You can Use .toFixed(2) method in javascript $('.share_info span').text(parseFloat(value_share).toFixed(2)) ...

how to send my sql to use magento pager

php,magento,mysqli,limit,pager

Please have look on below code for product collection and setting the limit for page size. $collection = Mage::getModel ('catalog/product') ->getCollection() - ->addAttributeToSelect('*') ->setPageSize($this->getRequest()->getParam("limit")) ->load(); Please adopt customer collection page size from above and let me know. ...

MySQL Select with Offset is Faster Than no Offset

mysql,performance,inner-join,limit,offset

Case 1: The optimizer can use an index on the ORDER BY. LIMIT 10 will be faster than LIMIT 10000,10 because it can stop reading rows sooner. Case 2: The optimizer cannot (or chooses not to) use an index for the ORDER BY. In this case, the entire set of...

C - Find all amicable numbers between limits

c,range,limit

You could write main() like this: int main () { // assumes 1 <= min <= max long min = 1; long max = 10000; long n = max - min + 1; long * s = malloc (sizeof(long) * n); long i, j; for (i = min; i <=...

Using a handler to delay a repeated task for a limited number of times

java,android,limit,handler,delay

There are a number of ways to do this, including something like what you have done here. The first thing to do is remove the while() loop at the end of your Runnable and instead just have the Runnable post itself as long as the count is less than 49....

Limit number of characters in input

javascript,html,input,limit,onkeypress

This can be done with html <input type="text" name="username" maxlength="14"> If you dont trust client side validation: $maxlength = 14; $string = $_POST['string']; if([url=http://us2.php.net/manual/en/function.strlen.php]strlen[/url]($string) > $maxlength) { $string = [url=http://us2.php.net/substr]substr[/url]($string, 0, $maxlength); ...

Limit On Accumulated Column in MySQL

mysql,sql,limit

There are many ways to do this. One is by using Correlated Subquery SELECT id, count FROM (SELECT *, (SELECT Isnull(Sum(count), 0) FROM yourtable b WHERE b.id < a.id) AS Run_tot FROM yourtable a) ou WHERE Run_tot < 50 ...

Wordpress posts_per_page not working

php,wordpress,loops,limit

Okay, I got it. This parameter is missing. Wordpress ignores "posts_per_page" by default for sticky posts. $args = array( 'post__in' => $sticky, 'orderby' => 'date', 'order' => 'ASC', 'posts_per_page' => 1, 'ignore_sticky_posts' => 1 ); ...

Set a limit in the results (no mysql)

php,limit,result

You mention "extracted from a folder" and also "or must necessarily the database" so I'm not sure what your source is. If you are getting the list of images them from a folder, presumably using something like glob() or readdir() or scandir() then you end up with an array. If...

Select percentage of rows from SQL table?

php,mysql,sql,limit

You can COUNT all records and then calculate the % you need like this: $query = "SELECT COUNT(*) FROM `Flight_Data` WHERE DepDateTimeUTC LIKE '%1/1/14%' "; $result = mysqli_query($connection,$query); $row = mysqli_fetch_row($result)); $total = $row[0]; $percent = intval($total * 0.40); $query = "SELECT * FROM `Flight_Data` WHERE DepDateTimeUTC LIKE '%1/1/14%' LIMIT...

Maximum value on JTextField

java,swing,limit,jtextfield

But it doesn't work (I can't type anything). if (Double.parseDouble(s) > 12345) { fb.replace(0, 5, "12345", attrs); } If the value is > 12345 you update the document with a hardcoded value. But, if the value is < 12345 you don't do anything. You need to insert the typed...

Pig - Unable to evaluate Limit expression: NULL

apache-pig,limit

Pig documentation clearly states that you can not use any columns from input relation with LIMIT operator. Either it should be a constant or a scalar. In your case you are using cnt which is a column in input relation.

List entries on multiple criterias, paginated

mysql,sql,select,sql-order-by,limit

Try this: SELECT a.id, a.order, a.highlighted FROM tableA a ORDER BY a.highlighted DESC, (CASE WHEN a.highlighted = 1 THEN a.order ELSE a.id END) DESC LIMIT 30, 10; ...

How to optimize order by and limit?

mysql,optimization,limit

You're building up a big dataset and sorting it, only to discard 60K rows and show 20. That work can be cut down by a so-called deferred join. The sorting still has to happen, but it can take less memory, and so be faster. Edit get the subquery into a...

Does MAX_PATH issue still exists in Windows 10

path,limit,long-filenames,windows-10

The issue will be anyways present in Windows, to keep compatibility with old software. Use the NT-style name syntax "\\?\D:\very long path" to workaround this issue.

How to improve ORDER BY … LIMIT … query peformance?

mysql,performance,limit

Try using the deferred-join pattern, as follows, to speed up this query. As it is, you're sorting tons of data. This query SELECT id FROM dedict_uniqueWF ORDER BY id LIMIT 1,20000 gets you the ids you need. Then this query uses that list of ids to access just the required...

Python selection limiter

python,select,filter,boolean,limit

I Have improvised code from @FunkySayu. def questionHairstyle(): while True: questionsH = [" 1, for bald;", " 2, for crew-cut;", " 3, for curly;", " 4, for wearing a hat" ] print("Please enter a hairstyle:") print("\n".join(questionsH)) hairchoice = raw_input("-->") #This will take even spaces print() if hairchoice in ["1", "2",...

PayPal API call daily limit

api,paypal,limit

I've never run into any daily limit issues with API calls. That said, I try to avoid hitting the API that many times. I would recommend you take a look at Instant Payment Notification (IPN). It will automatically POST details about transactions to a URL listener you have on your...

PHP SQL Server Alternative for TOP and LIMIT of MYSQL

php,sql,limit

Look at these posts. Simulating LIMIT from MySQL is little bit tricky. LIMIT 10..20 in SQL Server How to implement LIMIT with Microsoft SQL Server? From SQL server 2012 there is OFFSET and FETCH. SELECT * FROM Table ORDER BY FirstName OFFSET 10 ROWS FETCH NEXT 5 ROWS ONLY; It...

How to set nginx max open files?

linux,ubuntu,nginx,limit

I found the answer in few minutes after posting this question... # cat /etc/default/nginx # Note: You may want to look at the following page before setting the ULIMIT. # http://wiki.nginx.org/CoreModule#worker_rlimit_nofile # Set the ulimit variable if you need defaults to change. # Example: ULIMIT="-n 4096" ULIMIT="-n 15000" /etc/security/limit.conf is...

matlab function limit NaN value

matlab,math,limit

This is the function plotted for n=1. n is definitely not the limit. The function returns the correct value. ...

Capping each member in an r array

arrays,r,vector,limit

See ?pmin, or parallel minima calculation: pmin(150,losses) #[1] 25 150 5 17 2 150 12 8 75 5 50 1 If you need to do this multiple times, it would be beneficial to collect your variables in a data.frame or list. E.g.: dat <- data.frame(losses,aoi) data.frame(Map(pmin,dat,150)) # losses aoi #1...

PHP-MySQL: Limit data with a specific characters

php,mysql,data,character,limit

I think I found the solution: $email = '[email protected]'; $user = strstr($email, '@', true); // after PHP 5.3.0 echo $user; // name ...

Limit a view in Django

django,view,user,limit,extend

Without knowing a specific Django solution I can help you with a Python solution. If you use decorators you can limit the access to the webuser view: # Decorator for limit access when user dont have relation with WebUser def webuser_required(f): def trace(*args, **kw): try: login = isinstance(request.user.webuser, WebUser) return...

LIMIT doesn't work in datetime comparison

php,mysql,datetime,limit

My opinion - you are mixing things in your mind and misunderstood the LIMIT syntax idea. According to documentation: SELECT * FROM tbl LIMIT 5,10; # Retrieve rows 6-15 because as @zerkms noticed in comments: LIMIT [OFFSET, ] NUMBER that means in your case: limit 300, 400 must return max...

Getting LIMIT syntax error on MySQL [duplicate]

mysql,sql,oracle,limit

Thanks to @Jim Garrison. The solution was to use the ROWNUM attribute: SELECT IDBAR FROM ( SELECT PARRANDEROS.FRECUENTAN.ID_BAR as IDBAR, COUNT(PARRANDEROS.FRECUENTAN.ID_BAR) c FROM PARRANDEROS.FRECUENTAN GROUP BY PARRANDEROS.FRECUENTAN.ID_BAR ORDER BY c DESC ) WHERE ROWNUM <= 1; ...

try to restrict ips via regular expression

regex,limit

This is a pretty specific question, but the answer, I suppose, is worthwhile. The number range 217-222 is captured with 2(?:1[7-9]|2[0-2]) In your IP example, don't forget to escape the dots 123\.142\.132\.2(?:1[7-9]|2[0-2]) ...

Per day limit on number of GCM requests per day

max,limit,android-gcm

After Google replaced C2DM with GCM, they took off all limits. SOURCE: http://developer.android.com/google/gcm/c2dm.html#history Prior to GCM (when it was still called C2DM): https://developers.google.com/android/c2dm/#limitations) The only limits you run into the GCM documentation is this: http://developer.android.com/google/gcm/adv.html#lifetime Quote from the above link: Note: There is a limit on how many messages can...

calculating the function limit interatively

matlab,limit,formula

OK, now that I know what you're after, what you could perhaps do is use that taylor command and expand about a point that is quite far off from where you want to compute the limit. If we set the expansion point to be where you want to evaluate the...

mysql query select limit when insert date column less than 10

mysql,sql,select,limit

Use a sub-query to find 10'th latest insertDate: select * from tablename where insertDate >= (select DISTINCT insertDate from tablename order by insertDate desc limit 9,1) order by insertDate desc I'm not sure if you want that DISTINCT in the sub-select or not. (I guess not...)...

JTextArea show last X lines

java,line,limit,jtextarea

I think this is the listener that you are talking about: https://tips4java.wordpress.com/2008/10/15/limit-lines-in-document/ It's simple to use: textComponent.getDocument().addDocumentListener( new LimitLinesDocumentListener(50) ); ...

Selecting serial and IP, but the rows with the same IP first

mysql,select,order,limit,multiple-columns

SELECT * FROM `AKA` WHERE ( `IP` = '%s' OR `Serial` = '%s' ) AND `Country` = '%s' ORDER BY `IP` <> '%s' ASC, `Serial` <> '%s' ASC, `Country` <> '%s' ASC, `Date` DESC LIMIT 20 ...

Maths Concept: Draw line to follow mouse, with a radius limit

math,line,limit,conceptual,radius

Paraphrasing from my above comment: radius = 100; angle = atan2(mouse_position.y-center.y, mouse_position.x-center.x); if (distance(center, mouse_position) < radius){ line_position = mouse_position; } else{ line_position = center + Vector(radius*cos(angle), radius*sin(angle)); } ...

Efficient way to get N rows order by complex expression in MySQL

mysql,performance,sorting,sql-order-by,limit

(Sorry, this is a negative answer, but that's life.) If you will accept the "best solution" being only twice as fast as what you have experienced, then Accept @Zsuzsa's. I'm here to tell you that it cannot be optimized without doing something about f(...). Here's why: The optimizer sees no...

What is counting on rate limit of soundcloud?

limit,soundcloud,rate

A play request is defined as any request against the SoundCloud API which would generate a URL for streaming audio content in its response. For example, a GET to http://api.soundcloud.com/tracks/3/stream returns a URL which you can use to stream audio content. This request would count against your daily rate limit...

How to get total amount of rows while using limit when using PDO prepared statements? [duplicate]

php,mysql,pdo,limit

You can use the SQL_CALC_FOUND_ROWS command to tell MySQL to return the total of the matching records $sql = "SELECT SQL_CALC_FOUND_ROWS * FROM `tab` WHERE `condition` = :condition LIMIT $page_size OFFSET $offset"; To get the total rows found you can run this query SELECT FOUND_ROWS() But, it is ofter much...

SQL LIMIT by end of the month

php,sql,limit

Use the LAST_DAY() function. Takes a date or datetime value and returns the corresponding value for the last day of the month. Returns NULL if the argument is invalid. mysql> SELECT LAST_DAY('2003-02-05'); -> '2003-02-28' mysql> SELECT LAST_DAY('2004-02-05'); -> '2004-02-29' mysql> SELECT LAST_DAY('2004-01-01 01:01:01'); -> '2004-01-31' mysql> SELECT LAST_DAY('2003-03-32'); -> NULL...

How to limit an array size in MongoDB?

arrays,mongodb,limit

You can use $slice as a modifier to $push when you update the document: $push: {"field": $each: ["val1", "val2"], $slice: -10} This will cause field to only consist of the last 10 elements (giving you a "rolling window" of values pushed into the field)....

Laravel, Faker - genereate timestamp before certain time?

php,laravel,time,limit,faker

No, there is no way in Faker to achieve limit on the time part. But forget faker for this little task: date('H:i:s', rand(1,54000)); // 00:00:00 - 15:00:00 ...

Update long SQL query with TOP clause

sql,sql-server,limit,clause

You should add the TOP on the result of the UNION. SELECT TOP 10 * FROM ( SELECT SalesTranHeader.id, CustID, OrgName, BillNo, TranDate, TranDesc, db = CASE WHEN trancode IN('T5', 'F2,' ,'F3', 'F4', 'F11') THEN 0 ELSE [amount] - [OtherTranAmount] - [HignTemp] - [Penalty] END, cr = CASE WHEN trancode...

How to limit the number of results of this MySQL query [closed]

mysql,database,limit

try this: select * from questions where question_topic = 'c' union select * from questions where question_topic in ("c","java") order by question_type limit 10; the first select gives you all the C questions and the second gives you the first 10. When you union you don't get duplicates...

Max number of open files per process in Linux

linux,pipe,limit,ulimit

There is no issue here. A pipe has two ends, each gets its own file descriptor. So, each end of a pipe counts as a file against the limit. The slight difference between 1024/2 = 512 and 510 is because your process has already opened the files stdin, stdout, and...

RODBC changing limit for group_concat

mysql,r,limit,group-concat,rodbc

You're trying to put two SQL queries into one call to RODBC's sqlQuery() method. You Can't Do That (tm). Call sqlQuery() for the SET query and again for the SELECT query.

Is there a way to get a range of records in Postgres using LIMIT keyword

sql,postgresql,range,limit

Use the OFFSET function. First 30000: SELECT * FROM artist t1 ORDER BY count DESC LIMIT 30000; 30001 to 60000 SELECT * FROM artist t1 ORDER BY count DESC LIMIT 30000 OFFSET 30001; 60001 to 90000 SELECT * FROM artist t1 ORDER BY count DESC LIMIT 30000 OFFSET 60001; ...

Run a query with a LIMIT/OFFSET and also get the total number of rows

sql,postgresql,count,pagination,limit

Yes. With a simple window function: SELECT *, count(*) OVER() AS full_count FROM tbl WHERE /* whatever */ ORDER BY col1 LIMIT ? OFFSET ? Be aware that the cost will be substantially higher than without the total number, but still cheaper than two separate queries. Postgres has to actually...

Size limit of a script for SQL Server on a Squirrel client

sql,sql-server,sql-server-2008,limit,squirrel-sql

I finally made a try/fail test on my validation environment (1 000 lines, then 2 000, then 5 000, ...) It worked until 100 000 lines. Then it failed. I increased the memory of squirrel from 256mb to 512mb. With this configuration, 100 000 lines worked but really slowed the...

How to calculate expressions in better accuracy

limit,floating-accuracy,floating-point-precision,maxima

(1) use horner to rearrange the expression so that it can be evaluated more accurately. (%i1) display2d : false; (%o1) false (%i2) horner (x^5-6*x^4+14*x^3-20*x^2+24*x-16, x); (%o2) x*(x*(x*((x-6)*x+14)-20)+24)-16 (%i3) subst (x=1.999993580023622, %); (%o3) -1.77635683940025E-15 (2) use bigfloat (variable precision) arithmetic. (%i4) subst (x=1.999993580023622b0, x^5-6*x^4+14*x^3-20*x^2+24*x-16); (%o4) -1.332267629550188b-15 (%i5) fpprec : 50 $...

Limit the max number of rows in column MySQL

mysql,table,phpmyadmin,limit,rows

CREATE TRIGGER check_user_number BEFORE INSERT ON users FOR EACH ROW BEGIN IF (SELECT COUNT(*) FROM users) >= 60 THEN CALL 'Cannot add row, the number of users is limited to 60!'; END IF; END; ...

SPARQL using subquery with limit

nested,subquery,limit,sparql

You can use limits with subqueries You can use limits in subqueries. Here's an example: select ?x ?y where { values ?x { 1 2 3 4 } { select ?y where { values ?y { 5 6 7 8 } } limit 2 } } limit 5 --------- |...

Why does loop stop after being called 63 times? It should run to the end but stops for 90 mins after 63 calls

asp.net-mvc,iis,controller,limit

Google Chrome redirect loop error was causing the problem as it was detecting that this was an infinite loop

Notepad++: Delete everything after a number of characters in string

regex,notepad++,limit

This should work for you: Find what: ^(.{1,14}(?<=\S)\b).*$ Replace with: $1 so for Hell, how is she today ? the output is: Hell, how is DEMO ^ # The beginning of the string ( # Group and capture to \1: .{1,14} # Any character except \n (between 1 and 14...

randomInt function that can uniformly handle the full range of MIN and MAX_SAFE_INTEGER

javascript,algorithm,random,integer,limit

A solution that works, and the route that I have gone down is to use a BigNumber library. I still feel that there must be a solution to this problem without the need to rely on a BigNumber library, but I haven't found any other way as of yet. console.log(window);...

MYSQL LIMIT on COUNT of DISTINCT row

mysql,subquery,limit

This query may return the result you specified. The inline view t2 returns the maximum Season for each Series. The inline view t3 returns the maximum Episode for each Season of each Series. The results from the inline views (derived tables) can be joined to the original table, to retrieve...