Finding Number Of Records
I'm attempting to query a database to find out how many occurances of a particular value exist. So I'm trying to select where the same VendorNumber occurs less than twice, or more than twice. If it only occurs twice I do not care. I would like to also be able to see what the Value of the VendorNumber is. I've tried various syntax with count, distinct, and having, but I'm not sure I understand how it all works. In brief, I have a table called Vendor, which has the following entries for the VendorNumber field:
123123
123456
123456
123789
123789
123789
I'd like the query to tell me there is 1 occurance of less than 2, and there is 1 occurance of more than 2. It would be fine if these are separated out into two different queries to put into a php page. I'd also like to see the VendorNumber displayed.
View Complete Forum Thread with Replies
Related Forum Messages:
Finding Records
Need to setup a query that checks a certaid field for any value, what is the syntax for that? $query = ("SELECT * FROM `tbl_customers` WHERE `sales_rep` LIKE '%$any_value%'");
View Replies !
Finding Records Within The Last 48 Hours?
I can't seem to find anything on querying to find records dated within the last 48 hours. Not just two days/calendar dates, but 48 actual hours. I'm hoping to do something like: SELECT record FROM table WHERE postdate > (NOW - 48hrs) does that make sense?
View Replies !
Finding Unique Records
I have a database full of people details. And I want to extract each unique Nationality, then count how many of the nationality there are. Make sense? So i end up with a table like: English: 23 French: 36 German: 2 etc
View Replies !
Finding Only Records That Don't Match
I have a MySQL query that is supposed to pull records from a 'links' database. In the website, users can vote on links so I register a vote in a vote table with a link id and a user id. I need a way to pull all links that do not have a matching record in the vote table that has a specific user_id. Code: SELECT * FROM links, votes WHERE votes.link_id = links.id AND votes.user_id != 1 The problem is that there may be several records in the vote table for a single link_id. If user 1 has voted on link 800, and so has user 2, then this query will still pull link 800 because it finds a record in votes where the user_id is not 1. How can I change it so that NO records from the links table are pulled if the votes table has a record for the link_id and the user_id? If user 1 has voted on link 800 then I want to completely ignore link 800. If user 1 has not voted on 800 then I want to pull link 800.
View Replies !
Finding Records Relative To The Primary Key
To enable 'previous' and 'next' arrows on a page, I need a way to query my database and find the two records that have next lowest and the next highest value of the primary key field "primaryid". I realize that these values won't necessary be the current record "-1" or "+1", since after deletions a newly created record doesn't have just the next value up from the existing highest value for the primary key field. Code:
View Replies !
Finding A Whole Number
I have an upgrade script where the user chooses a number to upgrade by, I do not want them to be able to upgrade by .3 or .8, only numbers divisibal by 1, How can I find if they are trying to use a decimal?
View Replies !
Finding Highest Number
I have some files in a folder called "file1.png", "file2.png", "file3.png", etc. I was just wondering if there was a way to find which the highest number in the file name.
View Replies !
Finding Number In A String Of Numbers
I have a string of numbers separated by comma ',', eg $str = "1, 3, 56, 8, 9, "; (there's a comma at the end, because it was easier for me to do so) I need to compare a number ($id) if it's in the string. At first I thought, that strpos() will do the trick, but then it struck me, that 6 will be found (because of 56, ).
View Replies !
Finding The Number Of Arrays After Explosion?
If I have data I wish to explode, say: $text = 'hi, there, everyone, ..., .., ......'; $arr = explode(", ",$text) How do I find out how many items are in the exploded array, if I do not know how many items are in the imploded $text variable?
View Replies !
Number Of Records
I want to find out how many records, but I am using LIMIT in mySQL so if set the limit to 20 and I have 56 records then it will display 20 instead of 56. I have been using: mysql_num_rows What should I be using?
View Replies !
Counting Number Of Records
I am trying to do 2 things. First, i want to count all the records that i get when i query the db. Second i want run a loop to display all of the info. The loop works fine, (it displays all the results) but when i try to count the records, it only echo's 1. Here is the code i'm using. PHP Code:
View Replies !
Adding A Number To All Records
is there a query structure that will enable me to add, say, 10 to all records in a certain column without doing 2 queries for each record (one to get the current value and one to update it with the new value.
View Replies !
Counting The Number Of Records In Table
I want to count the number of records which apply to a repeating id field. (the user id remains the same, but their are several records which relate to the user. I want to know how many records in the table exist for a specified user id) Does anyone know a function for doing this?
View Replies !
Counting Number Of Related Records
I have a database which contains a listing of employee names along with the results of completed exams they have done. So each record contains their name and the name of the exam they have completed. What I'm trying to do is pull out how many exams each employee has done, and then email myself a message when all 15 exams have been completed. Code:
View Replies !
Delete Fixed Number Of Records
i have a table with one field. this field saves times as records. i want to there are 40 recoreds always. in other mean when inserts 41'st record then 1'st record be delete how to delete fixed number of records at a time of first of my records asc (like select). in other mean i want to like: delete from table order by time asc limit 0,1
View Replies !
Count Number Of Records Returned
I want to know how many records were returned from a stored procedure. $rs=odbc_exec($conn,"EXEC select_Contacts ".$sessionID); I have tried: odbc_num_rows($rs) but it always returns -1 even though records are printed out.
View Replies !
Suffix A Number To Duplicate Records
When querying the DB for records, many of the records have the same name. These names are not really duplicates because they are unique. For the records returned that have the same name, I would like to suffix a number at the end. For example: john01 john02 chris01 chris02 chris03 tom jack Btw, I do not want to add the incremented ID, because there are many records, 100,000+ and above. The ID would be too big of a number to add as a suffix. I need to add the suffix number to the duplicate names and not to the names that do not repeat.
View Replies !
Display Problem (number Of Records)
My company sends out a newsletter displaying new artwork aquisitions- my boss would like to have the number of works that we have by an artist displayed next to their name. Meaning- we show the image- then the artist name and the name of the artwork. He would like for the right number to show up in parenthesis next to the artist name. We have that displaying in another area (in a drop down search box). When you pull down the box it autopopulates with artists in the database and shows the number next to their name. Code:
View Replies !
Show Number Of Records Held
I want to display the numbers of records shown in each County on my database. PHP Code: mysql_connect($host,$username,$password); mysql_select_db($database) or die( "Unable to select database"); $query="SELECT county 'Bedfordshire', 'Berkshire' FROM t_data"; $result=mysql_query($query); $num=mysql_num_rows($result); while ($row = mysql_fetch_array($result)) { $Bedfordshire = $row["Bedfordshire"]; $Berkshire = $row["Berkshire"]; } How dow I show the number of records on Bedfordshire, Berkshire etc. I am echo'ing $Bedfordshire which shows the data not the number of Bedfordshire records held.
View Replies !
Retrieving And Writing Out A Large Number Of Records
I'm querying a remote mysql database and retieving a large number of records (600K records with about 12 columns for each record) which I am then writing out to a file on the local machine. I'm having problems with the process timing out, I only get about half of the records, and I'm wondering if there is a better solution then the one I'm using? Either inncreasing the timeout, or better yet by optimizing my code? Mysqldump is not an option for me at this point. Code:
View Replies !
Sending Variable To Display Number Of Records To Write?
Sorry, couldn't come up with any reasonably short subject. I am sort of new to PHP. I've got an event registration database (MySQL). In it, I have two tables, one for the registrant's info, and one for the reservations. Assuming that one registrant can make more than one reservation. There are 4 types of registrations. What I would like to do is to have the first page filled out with the registrant info, and have the registrant select the number of each type of reservations he/she would like. These numbers will not be written to the database, but will be used to determine how many of each type of reservation will be shown in the next window. Once the info is submitted (and written to the database), the user will then be taken to another page where they will enter the name for each registration, as well as the entree choice. so, the question is, how to do that (I will be passing the RegID as the primary key from tblRegistrant to use as the linked field to tblReservations). Ideally, I'd also like some sort of edit button so people don't try to use the back browser button to change their numbers. Any suggestions?
View Replies !
Count,sort,diplay Number Of Records In MySQL Table
I am designing a search engine using PHP/MySQL and I am logging all search terms into a MySQL table. I was wondering how I count the number of occurences of a term in the table, and then sort and display the terms in descending order. For example, if the column in my table with search terms looked something like this: clothes casinos clothes homes homes clothes How can I count and order the records so that I can display according to how many times they appear, like so: 1. clothes(3 entries) 2. home(2 entries) 3. casinos (1 entry)
View Replies !
Create Dynamic Table With 3 Columns And Unknown Number Of Records?
I'm trying to create a table with only 3 columns, but the problem is I don't know how many records will populate the table so need it to automatically create <tr> and </tr> tags every 3 records. How best can I do this? At present the code below just lists every single record in one continuous row - but as I said, I want to only display 3 records per row. Code:
View Replies !
Finding Last Digit In 2+ Digit Number
Is there a way in PHP to take a two or greater digit number and find the value of the last digit. For example, if the number given is 3718, is there a PHP function to find out that the last digit is an eight?
View Replies !
Displaying Priorty Records And Normal Records In The One Dataset.
I have a page which displays the records from the database and uses paging to display the records in groupes of 10 per page. I now want to be able to show results depending on the database field (display) in the database (can be set to either "full" or "limited"). If the record and the field display is equal to "full" i want to then display this record at the top of the record set and display all the fields. If the record is equal to "limited" i want to display different results and they must show after all the records which are equal to "full". I can't output two different recordsets as i use paging and only want to show 10 records per page. Code:
View Replies !
DELETE RECORDS - Database Adding New Records
iv got the database adding new records, and now I want it to display all of the records that are there buy name and id number, then i want u to be able to type in the id number of the customer u wish to delete and it shoudl delete it, sounds good buts its not actually deleting the record. it says it does, but its not doing it. Code:
View Replies !
Problems With The Listing Of Records, Editing Of Records
I'm having problems with the listing of records, editing of records, and deleting of records. I'm not sure what I'm doing wrong. The listing script is calling the add entry script. So I add the record, the database is updated, and nothing else happens. I don't get a list of records from that table. When I did SQL programming off the mainframe, you did a simple select statement. I'm not sure why the PHP list script is calling the add entry script. Code:
View Replies !
Replace Hex Number Or Decimal Number In A String ?
String may contain alphanumeric values. What is the bestway to replace a hex number such as 0x122aaa and decimal number such as 5678 with a string "blah" Example: I want to replace below-- wr_thru1 data or mask mismatch!! for addr=0x00000b73a0540 & mdfid:11 with wr_thru1 data or mask mismatch!! for addr=hexVal & mdfid:decVal
View Replies !
Get The Field_id Where The Number 22 Exists In The Number Column
I need to do the following. Say I have a table like this, I would like to get the field_id where the number 22 exists in the number column. Code: -> +------------+------------------+ | field_id | numbers | +------------+------------------+ | 1 | 12, 19, 22 | | 2 | 9, 22, 14 | | 3 | 11,6,88 | | 4 | 1, 16, 22 | +------------+------------------+ <- ...
View Replies !
Order Query By Number Only Reads First Number .
I have a result page which has price lists, but for some reason the code cannot distinguish between 25,000 and 5,000. Another words in a DESC price result, i get: 80,000 78,000 72,000 6,000 52,000 42,000 It reads the first number, and if first number is the same it reads second, but how do i get it to Order by the entire Number?
View Replies !
Order Number Or Tracking Number
I need to create some kind of random number within a persons session that can be inserted into a customer id column for their orders, customer, and credit card tables. Unless their is a better way to link a customers information together between a few tables besides using auto increment. Things could get screwed up for me if I use auto increment, especially if someone submits their information but does not actually place an order. My question is " How can I create a random order number that can be used within a persons session and will stay the same throughout the whole program for that one person? "
View Replies !
Difference Between The Current Number And The Next Number
I need a little help writing a math formula in php. I want to find the difference between the current number and the next number that will divide evenly into X. For example: I have 7 rows of data in my table. If I divide 7 by 3, I have a remainder. The next number that can be divided by 3 with no remainder is 9. I'd like to return 2.
View Replies !
Number Format - Convert Number.
This should be SSOOO simple, but I'm having a brain cramp this morning or something. How can I convert: 0.475 To 48% I'm sure there are some simple PHP commands that I already should know by now to convert that number.
View Replies !
Database Stores Default Number Everytime, But I Havent Set A Default Number??
Im having some problems with my database. Everytime i store a number which is longer than 10 numbers the script or database puts this number into the database: 2147483647. Its does this everytime no mather how i write the numbers and nomather how long the number is, it just needs to be over 10. I have set any default value in the database and to be sure i havent i tried deleting the table, but same thing happends again???
View Replies !
Finding Id Value
i am using php and mysql for this. i only want to keep the last 5 entries in the database. so i will add an entry in, which will have an ID value, then i want to delete the id with the lowest value, which in turn will be 6 from the last entry added. so the code will look like this: $oldid = $newid - 6; $deletethis = mysql_query("delete from table where id = $oldid"); is there a simple way to find the value of $newid ?
View Replies !
Finding The ID
I want to limit the number of records in the mysql database I have to 100, at any time - but there will be constantly new records being inserted via PHP. So, just before it writes the new record in the PHP script, I need to get the PHP to find the oldest record (based on date/time combo, or id), delete it, and then insert the new record. My question is, how can I detect which is the oldest record in the database? (either based on date/time combo or id)?
View Replies !
Finding IP
how to retrieve the IP address my ISP gives me. I don't have a static IP so it changes every once in a while and I'd like to write a script that retrieves my IP (not localhost) and email it to me. I can find out how to get it to email me but I'm stumped on how to find the IP.
View Replies !
Finding Key Instead Of Value
I have the following array: $names = array("Venore", "Folda", "Dame"); And I can print like this: $names[0]; -> return Venore $names[1]; -> return Folda $names[2]; -> return Dame but, what if I want to use: Code:
View Replies !
Finding A Tag
I'd like to know how to extract a tag from an URL. For eg, If i enter the URL http://youtube.com/watch?v=dYhhQhtrlFI I'd like the EMBED tag from the page to be extracted. How do i do it ?
View Replies !
|