When I use Max to find the maximum value of a field in a particular MySQL Group after using GROUP BY, is it possible to get the entire row which contains the maximum value?
I was wondering how can I allow NULL values in the following code below along with keeping WHERE username = '$username'.
here is the mysql code.
"SELECT *
FROM users
WHERE username = '$username'
AND user_id <> '$user_id'"
I'm trying to check for usernames with the same username but I want all users to have a NULL value if they want.
i'm developing an iPhone app which communicates with a remote DB.
for that purpose I'm looking for a web hosting service which inclues the following specs:
latest PHP
cUrl
SSL support
mySql
cron
live support
Max uptime
great money per value ratio
The main functionality is communication with the DB and displaying some info on the app.
It is important that the web hosting provider will be highly reliable.
Are there any providers who give some free usage before starting to pay?
Thanks
Hi,
It's possible to know if a MySQL server is overloaded (with PHP), and if it's overloaded show a static page (something like Twitter's fail whale)? How can I do it?
Thanks!
Excuse my ignorance.
I need to replace all data in a mysql field before and including the first # .
example field = golfers
data at the first hole the golfer missed a 9 inch putt and said "#hit it bad
new data hit it bad
I'm looking to calculate the number of months between 2 date time fields.
Is there a better way than getting the unix timestamp and the dividing by 2 592 000 (seconds) and rounding up whithin MySQL?
Given this SQL:
SELECT * FROM mytable ORDER BY mycolumn, RAND()
Assuming that mycolumn happens to only contain unique values (and hence, contains enough information to perform the ORDER BY), does MySQL short-circuit the operation and skip evaluating the rest?
I have a table of pages in my database, each page can have a parent as below:
id parent_id title
1 0 Home
2 0 Sitemap
3 0 Products
4 3 Product 1
5 3 Product 2
6 4 Product 1 Review Page
What would be the best MySQL query to select all pages ordered by parent then child then child again if there is more than one level, there will be a maximum of three levels. The above example would produce the desired order:
Home
Sitemap
Products
Product 1
Product 1 Review Page
Product 2
SQLite is a flat-file database and MySQL is a normal database. That's great but I'm not sure which is faster where or better for what? What are the pros and cons of each option?
Hi, I wonder if is it possible to run mysql command which can select an alternative field if the first given field is empty, on the same table.
Example : I have table called "posts" which have "intro" and "content". In the same statement I would like to select as a result "content" if "intro" is empty, but not having both in the result array.
Thanks in advance
Hi is there a free avaible translation backend with database avaible which can handle multiple users(no login needed), multiple languages (UTF-8) and provides automatic google translation?
I just need this tool to fill a database (preferable mysql) with simple tables like this:
language | label | text
english | _helloworld | Hello World!
german | _helloworld | Hallo Welt!
I don't care about export since this will have to be created anyways..
Thanks it would be a real timesaver if something with an usable UI exists already.
I read an article around schema-less database which sounds cool. (http://bret.appspot.com/entry/how-friendfeed-uses-mysql)
But what isn't clear to me is how do they run search queries on this data? Since the data is in JSON format how do we look for it?
I have a text file that looks like this:
value1
value2
value3
There are 32 million lines. Each line is terminated by a \n. The fields are not enclosed or delimited with any characters. I'm trying to import it into MySQL using this code, but it is not working:
LOAD DATA LOCAL INFILE 'data.txt'
INTO TABLE `table`
FIELDS TERMINATED BY ''
ENCLOSED BY ''
LINES TERMINATED BY '\n'
(`column1`)
Can anyone tell me what I'm doing wrong?
Is there any way to get the # of months and years since a date, using the mysql DATE column?
So if I enter 1/1/2009.. I want 1 years, 3 months.. and so on.
HI,
I have query having multiple regexp in where clause. The coloumns contained in the where clause have already been indexed.
But the query is not using the indexes.
Does MySql regexp cause use of indexes ? If not, what could be the workaround for this ?
I have a timestamp column in my database, and i use it for almost every field, but now, i just want to update the hit counter.. and i do not want to update the timestamp column with it. I use the timestamp field to see the last 'content' update. Not for every hit.
Is it possible to let mysql stop updating the timestamp column for just one query?
I have a table for image gallery with four columns like:
foid | uid | pic1 | pic2 | pic3 | date |
-----------------------------------------------
104 | 5 | 1.jpg | 2.jpg | 3.jpg | 2010-01-01
105 | 14 | 8.jpg | | | 2009-04-08
106 | 48 | x.jpg | y.jpg | | 2010-08-09
Mysql query for the user's galleries looks like:
SELECT * FROM foto WHERE uid = $id order by foid DESC
The thing that I want to do is count the number of images (PIC1, PIC2, PIC3) in every of the listed galleries.
What is the best way for doing that?
Hello,
Probably many coders want to ask this question. it is What's the adventages of each one of those MySQL time formats. and which one you will prefer to use it in your apps.
For me i use Unix timestamp because maybe i find it easy to convert & order records with it, and also because i never tried the DATETIME thing. but anyways i'm ready to change my mind if anyone tells me i'm wrong.
Thanks
What are the dangerous characters that should be replaced in user input when the users' input will be inserted in a MySQL query? I know about quotes, double quotes, \r and \n. Are there others?(I don't have the option of using a smart connector that accepts parameters so I have to build the query myself and this will be implemented in multiple programming languages, including some obscure ones so solutions such as mysql_real_escape_string in PHP are not valid)
I'm creating a database with what I anticipate will be a long (perhaps several paragraphs for some tuples) attribute. I'm assigning it text instead of varchar. I have two questions:
Should I give a maximum value for the text field? Is this necessary? Is it useful?
Since the contents of this field will be displayed on a website in HTML, do I need to include paragraph tags for paragraph formatting when I enter records into mysql?
I'm moving a locally developed wordpress site to a client's server so I'm trying to export the local database and import it to the server. I exported the .sql file according to the instructions here http://codex.wordpress.org/Backing_Up_Your_Database but I keep getting this error when importing:
DROP TABLE IF EXISTS `wp_commentmeta` ;
MySQL said: Documentation
#1046 - No database selected
Any help very much appreciated. Thanks!
Hello,
i am working with APE Engine (http://www.ape-project.org) and up until now i had no actual problem.
The problem is that i would like to use the MySQL module and push data to a channel each time a row is inserted into a table.
I've tried to setup a server side module, i created an SQL query but data is fetched only when the server boots.
How can i make this work?
hi,
i have an export sql file containing tables and data from mysql and i want to import it into a sqlite 3 db.
please can you tell me the best way?
i get error reading file in via sqlite3 binary.