Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
  Advanced Search
  HOME    TRACKER    MYSQL


SuperbHosting.net have generously sponsored dedicated servers to ensure a reliable and scalable dedicated hosting solution for BigResource.com.





Result Pull And Rating Sort


I have two databases. What I would like to happen is when I have a summary of products, I would like the query to pull the info from the product table and based on the id from that table cross reference with the reviews for that particular product and calculates all the reviews for that product into a single percentage. So when I access the assoc array from PHP I would like to see : Array(Array(['id'] => '2', ['prod_name'] => 'gummy bears', ['rating'] => '72'), Array(['id'] => '57', ['prod_name'] => 'socks', ['rating'] => '52')).




View Complete Forum Thread with Replies

Related Forum Messages:
How To Get To 50 Result And Sort Them
I want to ask, how to get to 50 result and sort them...

In my senario: I have country name's table having column (ID, country, visits)
Now I want to select top 50 country name by visits and sort them alphabeticaly...

So we have to use two different methods of sorting...

Select * from countries Order by visits,COUNTRY DESC LIMIT 50;

but it did not got top 50 by visits...
It print just 50 results....

View Replies !
Select Rating
My database looks like this:

id - service - ip - rating
62 - msc - 212.123.141.157 - 4
63 - hc - 123.123.123.123 - 2
and so on...

Now i want to calculate the average of all the ratings and display it on my site. How would i do that?

(i use php 4.3.8 + mysql)

View Replies !
Rating Queries
say I query a mysql database with keywords from a user(search engine) that results in many records. Is there a way to rate the results by having the records that have the most matches to the users keywords, with the goal of displaying them in descending order(a search engine)??

View Replies !
Rating Calculation
My current site requires calculated rating values. These ratings are submitted by users and they are either 1, 2, or 3. A simple average will not work because if one person votes 3, that will have as much weight as if 100 people vote 3. Also, simply using the sum feature is not ideal because 3 1's will equal 1 3.

Ones should mean that the rating should stay at one, but 3's could essentially increase. In other words, if a lot of people rate a question 1, it should stay at one, or even go below 1. But if a lot of people vote 3's, then it should raise above 3 by a little bit each time.

It is sort of like a parabola (remotely). It requires more mathematics than just adding. Does anyone have suggestions. I am currently using this and have tried avg in the past.

View Replies !
Rating System
i want to do a rating system like youtube's where it averages out the total ratings. i'd store each of the ratings per each row and have them seperated by comma's then in my code put them in to an array.

i also wanted to store the usernames of the voters in the database in the same fashion (without displaying them though) as above say instead of using cookies (as they can be deleted). would method this be feasible? or would this say overload the database and cause slow down?

View Replies !
Simple Rating System
I want to create a very simple rating system. User chooses from a drop down menu 1 to 10 and the result is shown next it.
The catch is i don't know about PHP or MySql. But i've been at this for several hours and i'm a fast learner.

If any of you have heard of it i am trying to use the free RateIt! script availble from http://www.skintech.org/rateit/install.php

But it keeps going on about creating a MySql table. a) i don't know how and b) i don't even konw why, what the table is used for. perhaps if i knew this i could understand it better.

View Replies !
Topic Rating System
I have a rating system on a forum I'm building. Users can rate a topic either good or bad. For each Good rating, one point is added to the topic's score. For every Bad rating, one point is subtracted to the topic's score.

Each time a rating is made, several things are inputted into a MySQL table called ratings

rating_id
rating_date
rating_username
rating_topic
rating_value

What I want to be able to do is query this table to grab the highest rated topics and lowest rated topics in a given time period. My MySQL knowledge is pretty limited right now.

View Replies !
Adding Places Depending On The Rating Score
I have:

Player | Rating
----------------
player1 1060
player2 1020
player3 980
...
playerN 640

The data is being sorted by rating DESC.
Now I'd like to add 'Place': 1st for the highest rating etc, like:

# | Player | Rating
-------------------
1 player1 1060
2 player2 1020
3 player3 980
...
n playerN 640

but I cannot figure out how to do so :confused:

View Replies !
Sort With Limit But Sort ALL Results.
I have a query that limits by 50 results at a time and I also have an order on a int field. The issue I'm having is it's only ordering by the 50 it returns, how can I have it order by the entire results set and then give me back only 50 results?

View Replies !
Pull All Records
if it were possible to write a statement in SQL where one could select several fields from a table and then limit the records returned by only displaying those where, say, FieldA (a varchar) contains a given short string which could be only a part of the field's contents. As long as a record has this short string in Field A, it should be included in the resulting set of records.Something like this:

SELECT FieldA, FieldB, FieldC
FROM TABLE Table1
WHERE FieldA *contains string*

Is there anything in SQL that could examine the contents of a field for a partial string, and then return the records that have that partial string in that field?

View Replies !
Pull All Usernames
Say I want to pull all usernames beginning with the letter A. How can I do so?

View Replies !
Multiple DB Pull
Lets say there is a database of special users and a database of favorite movies

SPECIAL USERS (username)
bob
jim

FAVORITES (username - movie_title)
bob - movie 1
kim - movie 3
jim - movie 1
larry - movie 2
jane - movie 2

How would I write a query that lists the most popular movies of special users without explicitly doing:

SELECT * FROM FAVORITES WHERE username = 'bob' or username = 'jim' GROUP BY movie_title

I want something like this:

SELECT * FROM FAVORITES WHERE username = [all the usernames from the SPECIAL USERS DB] GROUP BY movie_title

View Replies !
Mysql Pull
I got this in my mysql databe table.
a:1:{i:0;O:19:"test_Enclosure":4:{s:4:"link";s:36:"http://grabber/v/CAcpLiw4qt4.swf";s:4:"type";s:29:"application/x-shockwave-flash";s:6:"length";N;s:10:"javascript";s:2:"js";}}

I want to pull out only the
http://grabber/v/CAcpLiw4qt4.swf part?

View Replies !
Can Input Japanese, Can't Pull It Out
I figured out how to store Japanese characters by setting the collation of a particular field to utf8_bin. I can input Japanese characters, and I can see them just fine under PHPMyAdmin.

The problem is that when I execute a query and print them to a web page, all I get is question marks instead of Japanese characters. This is while using the same browser that allows PHPmyAdmin to display the characters correctly.

I added the following metadata to the <head> portion of the document but it didn't help:

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

View Replies !
Populate A Pull Down Menu From Db
how do I populate a pull down menu from a MySQL table?
Using PHP/MySQL 4.0

Have table1 with names and ID and tableb with ID and statistical info.wnt to be able to scroll names and have users able to click on the name to follow a link to a page created using tableb data for each name listed.


Table examples:
tablea
ID l Name
---------------------
1 Person, Joe
2 Smith, Joe


tableb
ID l units l margin
--------------------------------
1 5023 123
2 2536 72

View Replies !
Code To Pull Amount
I'm certain there is a function to do this but I forget what it is...
Say I am pulling values from the database, but I only want to pull like the first 10 chars of the value.. how do I do that?

View Replies !
Pull Hosting Plans
I am currently creating a web hosting website for a client of mine, for the packages and the order process we are using a script called "Auto-Host (http://www.idevspot.com/AutoHost.php)", which stores all the hosting plans into a mysql database.

This is a great script and it does exactly what we want it too, the only thing missing is it doesnt create a page where people can view the hosting plans and click a sign-up button. Can someone please give me guidance on how i can get a page with all the hosting plans on please?, alternatively i am willing to pay somebody for doing this on my behalf

View Replies !
How Can I Determine The Offset Of A Result In An Ordered Result Set?
How can I determine the offset of a result in an ordered result set?

I would like to pass the calculated offset into the limit half of and ordered select statement.

E.g. I have a table that records a id and datetime for captioned photographs. I'd like to show the five photos that were taken after the photo with id=23.

To do that I need to find the offset of photo with id=23 in

select id, datetime, caption from photos order by datetime;

Then I could get the result I want by doing....

select id, datetime, caption from photos order by datetime limit $offset, 5;

I've spent several hours scouring around and found some people with similar problems, but no solutions yet.

View Replies !
Pull The Last 10 Records From A Transactions From A Table
I'm trying to pull the last 10 records from a transactions from a table using this query:

SELECT * FROM transactions ORDER BY timestamp DESC LIMIT 10

But I want to display the rows in ascending order by timestamp. I can't get the subquery below to work and not sure why:

SELECT *
FROM (SELECT *
FROM transactions
ORDER BY timestamp DESC
LIMIT 10)
ORDER BY timestamp ASC;

View Replies !
Pull Related Info Using Subqueries
I'm creating a tool to browse a database of movie listings. The browser
pulls up 25 results at a time, and you can page through them using 'Next'
and 'Prev' tools. Pretty basic stuff.

Here are my tables:
movies
directors
comments
movies_directors
movies_comments
etc...
(primary key is movies.id)

But here's where I'm stuck: for each film, I need to pull the movie info in
'movies', plus any related data from other tables, like this:

The Lord of the Rings | Peter Jackson | 3 comments
Episode II | George Lucas | 0 comments
Indiana Jones | Steven Spielberg | 15 comments

I seem to run into problems when I try to join info from all of these
related tables. If there's a match, great. But, if not (like a movie with no
comments), the movie is excluded from the result set.

I've tried all sorts of SQL queries to make this work, but nothing seems to
do the trick.

SO, HERE'S MY QUESTION, IS THERE ANY WAY TO DO THIS QUERY WITHOUT
SUBQUERIES/MYSQL 4.0? Or would the best approach be to use PHP to do all the
subquery lookups?

View Replies !
Pull Similar Data From Two Tables
I need a query to search two seperate tables for similar data and return them in one result.

I know you can do multiple select statements in one query but I dont know how to exactly organize them into one result. Does anyone know how to accomplish this.

View Replies !
How To Pull Data From Multiple Tables
I have a db, with several tables in it, I have now reached to the point where I need to pull data from several tables. What is the best way to do this?

Should I put a column in each table, and then insert a unique key in all of them at the time the record(row) is being created? If this is the way to do it, when I am putting the unique key in each table would I just do an insert in each of the tables?

View Replies !
Pull Data From Multiple Tables
Can you pull data from 2 tables in the same database onto the same page? What about more than 2 tables?

Here is my dilema: I currently have a database with 1 table, and a ton of rows. The information is property information, and each property has multiple empty suites. As of now, I have columns for Building Name, Address, and then columns for Unit Type A (for the first unit), Rent A, Type B, Rent B, etc....

I was wondering if I would be able to put the listings we have into thier own property table, and then one bigger table of all the properties individual information. Keep in mind I need to call all tables together on my portfolio pages, so I would be connecting to quite a few tables at once.

Or my other option I was thinking about was to just have 2 tables: 1 Buildings info, and 1 units info.

Which of these would you do, or how would you organize this data.

View Replies !
Regular Expression :: Pull 3 Or 4 Digit Numbers
I would like to pull all the model number from my products table that are strictly only a 3 or 4 digit number ie:

034 or 3542 or 0243 or 934 etc

Can someone advise me on how to construct a regular expression to give me the data I need?I have tried the following but it wasnt 100% accurate:

Code:

products_model REGEXP "[[:<:]][0-9][0-9][0-9][0-9][[:>:]]" or products_model REGEXP "[[:<:]][0-9][0-9][0-9][[:>:]]"

View Replies !
Pull Data From Ibdata And Ib_logfile Files
I lost the data in a scheme and the only logs I have are the ibdata and ib_logfile files. Is there anyway to parse the data from these files to rebuild my data set?

View Replies !
Pull Info From One Database To Save In A Session To Push To A Different DB
I'm building a dynamic site that has 3 data bases. One DB contains all
of my store info ID#, Name, Address, Phone. Another DB contains member
info ID, Name, address, email,phone,etc...
The 3rd DB Tracks when a user logs in and logs out at a store. This DB
has the following columns Store ID, Member ID, log in time,log out
time, time in store.

The stores log in in the morning that starts a session-I need the
session to pull the store's info ID#, Name,etc... so when a user logs
in, in the store. The login page inserts the store ID, Store name, and
user ID into the 3rd DB.

There are a lot of stores how do I get the store variables to be
inserted into the DB?

View Replies !
Pull Data From 2 Database Tables Into 1 Table On My Site.
I got 2 tables: a dev_tasks and a task_history table. The task table has to record information about the task I am working on AND the history table is for the task history logs. I am trying to display info from both tables into 1 table on my site.

Most of the info will come from the dev_tasks table BUT i want to dedicate on column of the displayed info for the latest log made to the task_history table.

The common column to both tables is the 'taskid' column.

What would the query look like to pull the info from both tables, knowing that the taskid is common to both and that I want to display the last log per tasks from the task_history table?

View Replies !
Trying To Pull Id, Count And Title But Lose Rows When I Add Extra Join
i'm trying to extract some information from my database, the query being

PHP

SELECT grps_c.catid, grps_c.title, COUNT(grps.groupid) AS COUNT
            FROM grps
            RIGHT JOIN grps_category grps_c ON (grps_c.catid = grps.catid)
            GROUP BY grps_c.catid
            ORDER BY grps_c.title

which works fine. however some of the groups (grps.groupid) are hidden and i don't want to count them, so my thinking was add

PHP

LEFT JOIN grps_setting grps_s ON (grps_s.groupid = grps.groupid AND grps_s.hidden_group != &#391;')

however adding that removes the rows that have a 'count' or NULL or Zero.

View Replies !
Creat Mysql In Unix And Pull/post Data From A WindowsXP Machine With A UserDSN?
Can I creat mysql in Unix and pull/post data from a windowsXP machine with a UserDSN?

Is there an Administrative Tool (User DSN) that I can utilize to pull/post data to a Unix account without having to through the long process of "FTP" and "XTerm windows" ?

View Replies !
Keep Sort
The website is an ecommerce site that provides customers with the ability to "browse" the product line. In other words they can move from one item to the next until they get to the last item.
The question is: How can I insert a new item(row) and position it somewhere in the middle of the table? Currently, the table is sorted by the primary key which is numbered 1, 2, 3, etc. (whole numbers). Obviously I can't assign the same primary key to two items. My only thought is to use decimals in the primary key instead of whole numbers. So a row entered between 1 and 2 would be 1.1, 1.2, etc.
Does this make sense? Is there an easier way?

View Replies !
Sort Certain Value
I am displaying results from a table. One row, "position" contains values such as "President", "Vice President", or "None" (many of these).
Is there a way to order the results, alphabetically, by the "position" column, but sort any rows with a position of "None" to the bottom?

View Replies !
SORT BY
I have a very large table that is always sorted by the primary key when I SELECT data from it. Actually, the very purpose of the data being in a database is so that it can be sorted like that. I was wondering, however, if there's some way to use the WHERE clause in SELECT (or a seperate token) to actually give me, say, the 10000th entry if it were to be sorted. Something along the lines of:
SELECT name FROM data WHERE %place% = 10000 SORT BY income DESC
So basically if I had a database of names and their incomes in no particular order, I would need to find the name that has the 10000th highest income.

View Replies !
Sort
I have a table "users" with fields like:
first_name, last_name, photo_name, date

"photo_name" values are either NULL or
something like
"2_50_tim45.jpg"
"3_50_franky70.jpg"
"4_50_john_long.jpg"

Meaning not all users submitted their photos and those I would like to show at the end
of my HTML table.How do I make a query so that I would get result set that would show first users that have "photo_name" and then they would be sorted by
date.

SELECT * FROM users

View Replies !
Sql Sort
Code:
$sqlquery = "SELECT * FROM $ssl_table WHERE user='$login' ORDER BY date DESC, ticket_host DESC";

I'm using this query and want to sort a list by date and then by Alphabetical order for the teicket_host.

Yet it out puts like this:
2007-01-19 BH
2007-01-18 HM
2007-01-18 HM
2007-01-18 BH

The date is good but the 2nd Sort is not doing Alphabetically. I want it to go:
2007-01-19 BH
2007-01-18 BH
2007-01-18 HM
2007-01-18 HM

View Replies !
Sort Something
sort a list by name and birthplace but I don't really know how to do that. Can anyone give me an example?

View Replies !
Sort, Limit
I am trying to do a query like:

(SELECT * FROM table1 ORDER BY frequency DESC LIMIT 50)
ORDER BY name;

Where the top 50 frequency values are then sorted by name. When I try
this, it displays each equal frequency value sub sorted by name (so all
freq = 50 are shown a-z, then all freq=40 shpwn a-z etc), rather than
showing the top 50 frequencies sorted by name which is what I want to
achieve.

View Replies !
SQL Sort (Order By)
I have sql statement below ,


SELECT
serial_no,host_name,chasis_model,chasis_flash_size ,chasis_dram_size,
country,city,building,other,chasis_sw_version,stat us,chasis_eos,chasis_eol,chasis_user_field_1,chasi s_user_field_2,chasis_user_field_3
FROM tbl_chassis ORDER BY country = '', country


However , my user would like to sort by country,city,building and other
columns .
Anybody have ideas how to do that ? I do order by
country,city,building,other gave me the result which i not expected.

For example below data before sort

Country City Building Other
Thailand Bangkok 208 Wireless RD
Thailand Bangkok 208 Wireless RD
Thailand Bangkok 208 Wireless RD
Thailand Bangkok 208 Wireless RD
Thailand Bangkok 83 Aber rd
Thailand Bangkok
Thailand Bangkok 12 Godieon Rd
Thailand Bangkok 900 Telepark

After sort

Country City Building Other
Thailand Bangkok 83 Aber rd
Thailand Bangkok 12 Godieon Rd
Thailand Bangkok 900 Telepark
Thailand Bangkok 208 Wireless RD
Thailand Bangkok 208 Wireless RD
Thailand Bangkok 208 Wireless RD
Thailand Bangkok 208 Wireless RD
Thailand Bangkok

View Replies !
Sort Asc W/ Most Recent
I want to display the five most recent rows in my table (there is a timestamp), but sorted in ascending order.

the problem is that when i call

SELECT * FROM spam ORDER BY time ASC LIMIT 5

it shows the first five entries in ascending order, but i want the last
five.

needless to say, it works fine with descending order..

View Replies !
Sort NULL Last
I have a mysql query, "SELECT * FROM task ORDER BY duedate ASC", where
"duedate" is a unix_timestamp and can be NULL. I want any NULL results
to be at the end of the list, how might I do this?

View Replies !
Sort With GROUP BY, HAVING
I've got the following table:

id id_items id_fc nombre cantidad unidad precio moneda

1 1 0 Prod1 9612 unidad 152 dolar

21 1 1 prod3 150 NULL NULL NULL

9 1 0 prod3 500 ton 321 peso

20 1 1 Prod1 100 NULL NULL NULL

19 1 NULL NULL NULL NULL NULL NULL


I'd like to obtain registers grouped by 'nombre', with the data from the one (from the rows with same 'nombre') that has id_fc = 0 or NULL. This would be a unique row.

Also, I want a column to show the result of the SUM of 'cantidad' of all items with that 'nombre' minus the 'cantidad' of the selected item (the one with id_fc = 0 or NULL)

So, I tried the following query: ....

View Replies !
How To Sort Date ?
this is my table code

Code:

CREATE TABLE `attendance` (
`userid` bigint(255) NOT NULL,
`attdate` date NOT NULL,
`status` tinyint(1) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

View Replies !
Sort By First Letter
I would like to be able to sort by the first letter of a field.
I have a problem where I have business's in a list and would like it to be alphabetically sorted.However, the listings that are priority (paid listings are '1', normal are '0') listings, I would like these at the top of each character section eg, A, B, C etc..

View Replies !
Sort By Relevance
I'm building a very simple search engine, it searches a number of database tables. At the moment I'm using Union to do a number of query and join them into a single set of results.Is there anyway I could implement a very simple sort by relevance kind of thing?

View Replies !
Sort By Tags
I have three tables:

- an article table
- a tags table
- a many-to-many table that links articles with tags

I have a page which displays the article together with the tags. (I already have the query for that)

Now I also want to add links with 5 related articles. The related articles should be articles that have one or more tags in common with the current article.

How can I write a query that finds related articles (as described above) and order the by relevance (meaning, how many tags they have in common with the current article)?

View Replies !
Sort Of Like Distinct
Is there a way to retrieve a set number of duplicate results?
For example, I have a calendar application and I want to retrieve only 4 results per day.
The data is like this:

Woo, 6
Yes, 6
Foo, 6
Bar, 6
Yay, 6

where those 5 entries are from the 6th of the month, so basically I want to limit each distinct date to 4 results.

View Replies !
ORDER BY Sort
When a number is stored as a character string, in what order does ORDER BY sort? ASCII-betical? Or numeric?
I can't believe I've spent half an unsuccessful hour trying to Google an answer to such a simple question!
I'm curious because I want to store a bunch of numbers, some integers and some decimals, and want to know if it makes any difference whether I store them all as decimals or as characters

View Replies !
Sort With A Limit
What I need to do is display results that are sorted based on user preference. These results need to be paged to display 25 results per page. Currently I'm using a simple sort and limit. However, as many of you smart folks know, MySQL only sorts the values it finds within the limits as opposed to sorting the whole table and then limiting results.

View Replies !
Natural Sort
how is possible sort rows in table like php function natsort - http://php.net/manual/en/function.natsort.php Values in my table.

- "35 - somethig"
- "51 - somethig"
- "06 - somethig"
- "01 - somethig"
- "02 - somethig"
- "08 - somethig"
- "ZC"
- "BA"
- "AA"

I need this order
- "AA"
- "BA"
- "ZC"
- "01 - somethig"
- "02 - somethig"
- "06 - somethig"
- "08 - somethig"
- "35 - somethig"
- "51 - somethig"

View Replies !
Sort List By Day
ive got a list of days i.e. monday, wednesday, friday etc. in random order.
The problem is i want to sort the list by the day of the week, so monday first then tuesday, wednesday etc. is it possible to do this?

View Replies !

Copyright © 2005-08 www.BigResource.com, All rights reserved