mysql-query

mysql query using jdbc

Hi all, I need to retrieve the last 20 values from my database.For example I have the following table Service_ID Service_Type consumer_feedback | 36 | Printer | 0 | | 36 | Printer | 1 | | 36 | Printer | 0 | | 36 | Printer | ...

MySQL, moving first word to last

How would I move the first word, if it was the word 'the', to the end of the cell in MySQL? As an example: before: The Good, the Bad and the Ugly after: Good, the Bad and the Ugly, The Thanks ...

Database INSERT does not take place

My code is as follows: <?php include("config.php"); $ip=$_SERVER['REMOTE_ADDR']; if($_POST['id']) { $id=$_POST['id']; $id = mysql_escape_String($id); $ip_sql=mysql_query("select ip_add from Voting_IP where mes_id_fk='$id' and ip_add='$ip'"); $count=mysql_num_rows($ip_sql); if($count==0) { $sql = "upd...

Trying to display text from mysql field starting 30 words into paragraph?

I can't figure this out for the life of me... Using wordpress trying to display excerpt from posts starting 30 words in.. php mysql Please help! ...

MySQL easy question CURDATE()

I want to compare two results one is stored in the first query, and the other is exactly the same as the first, but i want only to recieve data < today "SELECT s.GSP_nom as nom, timestamp, COUNT(s.GSP_nom) as nb_votes, AVG(v.vote+v.prix+v.serviceClient+v.interface+v.interface+v.services)/6 as moy FROM votes_serveur AS v INNER...

Script to create a table and fields in SQL wont work

Warning this is lenghty! attack if you knowledagble. well at least more then a newb beginner like me. This script uses three files as detailed below. It is suppoed to create the database and fields from the form input. It gets to the end and shows my_contacts has been created!. But when i go into phpMyadmin the table has not been create...

I want to search and replace multiple values in a table column in one MYsql querry.

Query to Where X update Y and where A update B in a Mysql Table column. How can I Do this in MYsql in one querry on the same column in a specific table. I want to search and replace multiple values in a table column. Conditons in table1 in column1 Where X update Y and Where a update b and Where 1 update 2 and Where 3 update 4 and Whe...

MySQL enters another value that the one given by PHP

Hello, The big problem : mysql does not stores the information i told him to via PHP Example (this req is an echo just before the query) : INSERT INTO serveur (GSP_nom , IPserv, port, tickrate, membre, nomPays, finContrat, type, jeux, slot, ipClient, email) VALUES ( 'ckras', '88.191.88.57', '37060', '100' , '', 'Allemagne','20110519...

Algorithm To Select Most Popular Places from Database

We have a website that contains a database of places. For each place our users are able to take one of the follow actions which we record: VIEW - View it's profile RATING - Rate it on a scale of 1-5 stars REVIEW - Review it COMPLETED - Mark that they've been there WISH LIST - Mark that they want to go there FAVORITE - Mark that it's on...

php MySQL snytax error

my scrip is supposed to look up contacts in a table and present thm on the screen to then be edited. however this is not this case. I am getting the error Parse error: syntax error, unexpected $end in /home/admin/domains/domain.com.au/public_html/pick_modcontact.php on line 50 NOTE: this is the last line in this script. <? session_star...

Unable to jump to row 0 on MySQL result index 13

What is the reason of the error on title? I tested mysql query at Mysql Front and no problem. My script is below. Thank you. $fbFoodPerma = $fbSiteID."-".$fbFoodPerma; $sql = mysql_query(" SELECT fbFoodPerma FROM fbFoods WHERE fbFoodPerma LIKE '$fbFoodPerma'") or die(mysql_error()); ...

MySQL limit from descending order

Hello, Is it available to write a query to use same "LIMIT (from), (count)", but get result in backwards? In example if I have 8 rows in the table and I want to get 5 rows in two steps I would: first step query: select * from table limit 0, 5 first step result: first 5 rows; second step query: select * from table limit 5, 5 se...

Is there anything else I can do to optimize this MySQL query?

I have two tables, Table A with 700,000 entries and Table B with 600,000 entries. The structure is as follows: Table A: +-----------+---------------------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default | Extra | +-----------+---------------------+------+-----+---------+-------...

php edit database entery script not working.

I have two .php files which show all contacts in a database, then allows the user to choose a contact to be edited. The first script is called pick_modcontact.php where I choose a contact, then posts to the script show_modcontact.php When I click the post button on the form on pick.modcontact.php the browser returns to that file due to ...

MySQL 5.1.41 leading zero is deleted

Hello, I have a MySQL database where i want to store phonenumbers among other things. The fieldtype is INT(10) When I try to insert a number starting with a 0, like 0504042858 it's stored like 504042858. This only happens with zeros when the number start with any other number it's stored correctly. What am I doing wrong? ...

Select random row from MySQL (with probability)

I have a MySQL table that has a row called cur_odds which is a percent number with the percent probability that that row will get selected. How do I make a query that will actually select the rows in approximately that frequency when you run through 100 queries for example? I tried the following, but a row that has a probability of 0.3...

Aggregate keeping the row with the max value

Suppose you have the following schema (id, user_id , score). How can I take per each user the row with max score and then order all row for score. In other word I want a ranking where each user have his best result. ...

MySQL Left Join using key1 or key2

I want to be able to use multiple keys to join two tables. Is the following possible? SELECT * FROM items LEFT JOIN issues USING (item_id OR order_id) This is a simplified version of what i am doing. using MySQL 5.1.36 in case that matters. UPDATE: I want all the issues joined, using item_id or order_id. So there could be multiple is...

mysql PDO how to bind LIKE

In this query select wrd from tablename WHERE wrd LIKE '$partial%' I'm trying to bind the variable '$partial%' with PDO. Not sure how this works with the % at the end. Would it be select wrd from tablename WHERE wrd LIKE ':partial%' where :partial is bound to $partial="somet" or would it be select wrd from tablename WHERE w...

Help with two SQL Queries

Hi, I’m having some difficulties with two queries. I can get some of the information but my problem lies in the some special conditions I just can’t seem to get right in the SQL statement. The first query is in natural language defined: I’m going to find all the candidates who has acquired two qualifications but during the same time p...