mysql

Query a list of names from one table that appear in a field in a different table

I want to query a list of names from one table that appear in a field in a different table. Example: table1.title>Tiger Woods Cheats, Tiger Woods Crashes, Brad Pitt is Great, Madonna Adopts, Brad Pitt Makes a Movie table2.names>Tiger Woods, Brad Pitt, Madonna So those are the two tables and values. I would like to write a query that...

SUM(a*b) not working...

I have a PHP page running in postgres. I have 3 tables - workorders, *wo_parts* and part2vendor. I am trying to multiply 2 table column row datas together, ie *wo_parts* has a field called qty and part2vendor has a field called cost. These 2 are joined by *wo_parts.pn* and part2vendor.pn. I have created a query like this: $scoreCostQuer...

Missing InnoDb Engine

I just went to look over one my site's databases and noticed that all of the tables had been converted to MyISAM (they used to be InnoDB). What's more is that InnoDB seems to missing, along with BerkeleyDB, Federated, and others. A few months ago I upgraded from MySql 5.0 to 5.1.38. I can't imagine that I wouldn't have noticed if Inno...

Help with a MySQL query

Hello guys, Given the following two tables: users (user_id, username, location, email) votes (user_id, value, date, ip) How can I perform a MySQL query to return all the users with total number of votes and sum of votes for each user? Thank you. ...

Modified preorder tree traversal - finding the next node

Hi, I have this data: id | parent_id | lft | rgt | name ===================================== 1 | 0 | 1 | 8 | abc 2 | 3 | 5 | 6 | jkl 3 | 1 | 2 | 3 | def 4 | 0 | 9 | 10 | mnno 5 | 1 | 4 | 7 | ghi I need to traverse this hierarchy in this order (ids): 1 > 3 > 5 > 2 > 4 H...

Single or multiple mysql rows? (shopping basket)

I am currently creating a custom e-commerce site (in php, but that's not really relevant for this question). I have just got to creating the shopping basket, and cannot decide between the following 2 options: option 1: Basket table: id user items In this option, I would have one row per user, with all of the items and quantities st...

Whats a better strategy for storing log data in a database?

Im building an application that requires extensive logging of actions of the users, payments, etc. Am I better off with a monolithic logs table, and just log EVERYTHING into that.... or is it better to have separate log tables for each type of action Im logging (log_payment, log_logins, log_acc_changes)? For example, currently Im loggi...

Implementation of Comments, Is there any best practice for this?

Well I need to implement the comments feature on a custom coded social networking website. The comments need to be implemented on various pages like videos, pictures, albums etc etc similar to facebook. What would be the best practice for implementing this ? Making one global comments table with fields like this, and grab comments base...

Select average from MySQL table with LIMIT

I am trying to get the average of the lowest 5 priced items, grouped by the username attached to them. However, the below query gives the average price for each user (which of course is the price), but I just want one answer returned. SELECT AVG(price) FROM table WHERE price > '0' && item_id = '$id' GROUP BY username ORDER BY pr...

How to let users add multiple tags using PHP and MySQL?

Okay, so I already have a script to let users enter tags but I want to let users enter multiple tags that are separated by a comma for example, (html, css, php) and store each tag in the database. Is there a tutorial that can show me how to do this or can someone give me a couple of examples that i can work from. Thanks ...

How can I link to a MySQL Database in Expression Blend?

Can any one point me to a tutorial, or tell me how to, connect a MySQL Database to a Silverlight Project in expression blend? Is an ODBC connection like this even possible in Silverlight? Thanks Sebastian ...

How to select the latest version of answers given by each answerer in MySQL?

There is a scenario. There is an ask-and-answer website. An answerer can modify his answer, and the history of modification is saved on the server. Be default, only the latest version of each answer is displayed. select * from answers where questionid='$questionid' group by answerer_id So I can group all answers by answerer, then I ...

What is MySQL Collation, how to use it in practice ?

Let's say I want to make a search engine in some weird languages in 4 languages: English Swedish Hebrew Arabic How would I set the collations in MySQL ? ...

PHP/MySQL - How to add multiple tags

I have this script that only lets users enter a single tag but I want to let users enter multiple tags that are separated by a comma for example, shoe, shirt, hat, glasses and store each tag in the database. Can someone please give me a couple of examples of what I need to change in my script in-order to do this. Here is my MySQL tabl...

add new session product - PHP

When a user is buying a product (lets say they have 3 products) and they have typed their information, the product automatically goes into database with a status = 0. If the user is going away from the basket, lets assume into product overview(and buying an extra product, now they have 4 products in basket). I have to find out how to...

getting mysql data after specific date

how can i get mysql data after a specific timestamp..........!! means what shoud be the query mysql_query("SELECT * FROM table where thenameoftimestamprow > than the date"); ...

Storing multiple tags in a MySQL database problem using PHP/MySQL?

First let me explain that I have this script that should let users enter multiple tags that are separated by a comma for example, shoe, shirt, hat, glasses and store each tag in the database. But for some reason the tags are not being stored in the database correctly. For instance when a user enters two or more tags they are stored all...

MySQL count rows performance

For an InnoDB storage is it better to count the total number of records with `select * from tbl where pk = 1` <em>retrieve mysql_num_rows</em> or with `select count(*) as total from tbl where pk = 1` *fetch the array and retrieve the "total" value* ? ...

Aggregating SQL rows with precedence

I have a table full of items from different sources. Some of the sources might have the same location (in my example, different BBC news feeds would be different sources, but they all come from the BBC). Each item has a "unique" ID which can be used to identify it among others from the same location. This means that items relating to the...

PHP/MySQL - Improper stored data when submitted by users?

First let me explain that I have this script that should let users enter multiple tags that are separated by a comma for example, html, css, php, mysql and store each tag in the database and associating it to the question it was tagged too. But for some reason the tags are not beign associated with the questions_tags table correctly to...