Re: Need help to query with timestamp in C++
Hi Saul, I need to use C++ and I'm not writing a web application. Thanks anyway. Kandy I have done queries to the database in PHP with variables like month but easily can select from a range of time and data to produce the same results, the output goes directly to the web so if that is what you are seeking for, I can help with PHP. Saul Kandy Wong wrote: Hi, I need to write a C++ program in a Linux environment to query with a timestamp. The user will only provide with an approximate time so I'd like to know how can I write a program or a query to return the closest data. The followings are the timestamp in the MySQL database: | 2008-08-05 03:56:09 | 1217933769 | | 2008-08-05 03:56:19 | 1217933779 | | 2008-08-05 03:56:29 | 1217933789 | | 2008-08-05 03:59:39 | 1217933979 | | 2008-08-05 03:59:49 | 1217933989 | | 2008-08-05 03:59:59 | 1217933999 | | 2008-08-05 04:02:39 | 1217934159 | | 2008-08-05 04:02:49 | 1217934169 | | 2008-08-05 04:02:59 | 1217934179 | For example, '2008-08-05 04:01:39' is the time provided by the user which does not exist in the database. So, how can I return the closest data? I know I can make use of 'LIKE' but this will return more than one data. What is the best method to get the closest one? And what is the good connector (C++ to MySQL) to use? Any suggestion? Thank you. Kandy -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED] -- Kandy Wong Scientific Programmer Analyst TRIUMF (Canada's National Laboratory for Particle and Nuclear Physics) 4004 Wesbrook Mall Vancouver, BC, Canada, V6T 2A3 Phone: (604) 222- 1047 ext. 6193 Email: [EMAIL PROTECTED] -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
ERROR 13 (HY000): Can't get stat of '/var/lib/mysql/e5publishers.txt' (Errcode: 13)
I am running MySQL Community edition 5.0.51a-0.rhel4 (on RedHat Enterprise Linux 4). I am unable to load data from a text file; when I try I get the error message in the subject of this email. In the typescript below you will see two tries, with all the necessary file and database permissions. In both cases the file and the whole path to the file is world-readable. I logged into MySQL using the root account, which has all MySQL privileges. What is going wrong here? [EMAIL PROTECTED] ~]# su - mysql -bash-3.00$ pwd /var/lib/mysql -bash-3.00$ mysql --user=root --password e5 Enter password: Reading table information for completion of table and column names You can turn off this feature to get a quicker startup with -A Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 39 Server version: 5.0.51a-community MySQL Community Edition (GPL) Type 'help;' or '\h' for help. Type '\c' to clear the buffer. mysql load data infile '/var/lib/mysql/e5publishers.txt' - into table e5publishers - fields terminated by ' '; ERROR 13 (HY000): Can't get stat of '/var/lib/mysql/e5publishers.txt' (Errcode: 13) mysql show grants; ++ | Grants for [EMAIL PROTECTED] | ++ | GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' IDENTIFIED BY PASSWORD '*snip*' WITH GRANT OPTION | ++ 1 row in set (0.00 sec) mysql Bye -bash-3.00$ ls -ld e5* drwx-- 2 mysql mysql 4096 Aug 15 01:34 e5 -rwxr-xr-x 1 mysql mysql 214256 Aug 15 01:30 e5publishers.txt -rwxr-xr-x 1 mysql mysql 2641 Aug 15 01:30 e5servers.txt -rwxr-xr-x 1 mysql mysql 178746 Aug 15 01:30 e5subscribers.txt -rwxr-xr-x 1 mysql mysql 627939 Aug 15 01:30 e5topics.txt -bash-3.00$ pwd /var/lib/mysql -bash-3.00$ ls -ld . drwxr-xr-x 5 mysql mysql 4096 Aug 15 02:25 . -bash-3.00$ ls -ld .. drwxr-xr-x 24 root root 4096 Feb 16 10:02 .. -bash-3.00$ ls -ld / drwxr-xr-x 27 root root 4096 Aug 15 01:50 / -bash-3.00$ ls -ld /var drwxr-xr-x 22 root root 4096 Sep 16 2005 /var -bash-3.00$ ls -ld /var/lib drwxr-xr-x 24 root root 4096 Feb 16 10:02 /var/lib -bash-3.00$ logout [EMAIL PROTECTED] ~]# cd /var/lib/mysql [EMAIL PROTECTED] mysql]# mv e5*.txt / [EMAIL PROTECTED] mysql]# ls -ld / drwxr-xr-x 27 root root 4096 Aug 15 02:26 / [EMAIL PROTECTED] mysql]# mysql --user=root --password e5 Enter password: Reading table information for completion of table and column names You can turn off this feature to get a quicker startup with -A Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 40 Server version: 5.0.51a-community MySQL Community Edition (GPL) Type 'help;' or '\h' for help. Type '\c' to clear the buffer. mysql load data infile '/e5publishers.txt' into table e5publishers - fields terminated by ' '; ERROR 13 (HY000): Can't get stat of '/e5publishers.txt' (Errcode: 13) mysql Bye [EMAIL PROTECTED] mysql]# ls -ld /e5* -rwxr-xr-x 1 mysql mysql 214256 Aug 15 01:30 /e5publishers.txt -rwxr-xr-x 1 mysql mysql 2641 Aug 15 01:30 /e5servers.txt -rwxr-xr-x 1 mysql mysql 178746 Aug 15 01:30 /e5subscribers.txt -rwxr-xr-x 1 mysql mysql 627939 Aug 15 01:30 /e5topics.txt [EMAIL PROTECTED] mysql]# rpm -q -a | grep -i mysql mysql-query-browser-5.0r12-1rhel4 mysql-gui-tools-5.0r12-1rhel4 MySQL-server-community-5.0.51a-0.rhel4 MySQL-client-community-5.0.51a-0.rhel4 mysql-administrator-5.0r12-1rhel4 [EMAIL PROTECTED] mysql]# Mike Spreitzer SMTP: [EMAIL PROTECTED], Lotus Notes: Mike Spreitzer/Watson/IBM Office phone: +1-914-784-6424 (IBM T/L 863-) AOL Instant Messaging: M1k3Sprtzr
Re: Need help to query with timestamp in C++
Hi Kandy, this could be the query you are looking for. It should return record with the closest timestamp to your required time: (SELECT TIMEDIFF('20080815091907', timestamp_column) AS diff, t.* FROM table1 t WHERE timestamp_column = '20080815091907' ORDER BY timestamp_column DESC LIMIT 1 ) UNION (SELECT TIMEDIFF(timestamp_column, '20080815091907') AS diff, t.* FROM table1 t WHERE timestamp_column = '20080815091907' ORDER BY timestamp_column LIMIT 1 ) ORDER BY diff LIMIT 1 HTH, Dusan Kandy Wong napsal(a): Hi, I need to write a C++ program in a Linux environment to query with a timestamp. The user will only provide with an approximate time so I'd like to know how can I write a program or a query to return the closest data. The followings are the timestamp in the MySQL database: | 2008-08-05 03:56:09 | 1217933769 | | 2008-08-05 03:56:19 | 1217933779 | | 2008-08-05 03:56:29 | 1217933789 | | 2008-08-05 03:59:39 | 1217933979 | | 2008-08-05 03:59:49 | 1217933989 | | 2008-08-05 03:59:59 | 1217933999 | | 2008-08-05 04:02:39 | 1217934159 | | 2008-08-05 04:02:49 | 1217934169 | | 2008-08-05 04:02:59 | 1217934179 | For example, '2008-08-05 04:01:39' is the time provided by the user which does not exist in the database. So, how can I return the closest data? I know I can make use of 'LIKE' but this will return more than one data. What is the best method to get the closest one? And what is the good connector (C++ to MySQL) to use? Any suggestion? Thank you. Kandy -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
Re: another INNODB vs MYISAM question
if you switch the default engine type any new tables would be created with that new engine type. it does not convert existing tables to your new format. if you have existing innodb tables you need to have the innodb settings active, in my.cnf On 15 Aug 2008, at 06:01, [EMAIL PROTECTED] wrote: Hello mysql, As I have previously mentioned, I installed WAMPSERVER 2.0 on my Windows XP pro box recently. It installed INNODB as the Default Engine. All of my legacy Databases are MYISAM and after the installation, I copied them all into the DATA folder and everything worked, even adding new tables etc. but the new stuff was INNODB. So I ended up with some MYISAM databases that contained INNODB tables in them. After a few weeks I got to thinking that mixing INNODB and MYISAM might not be a good thing and switched the Default Engine to MYISAM in my.ini file. I didn't just switch the default, I commented out all the INNODB calls in the my.ini file as well. As I half expected, all the databases that I had added INNODB tables failed when I tried to fire up the applications that used them. Although I am not new to mysql, I have had a bit of MYISAM tunnel vision with it so my question is, if I had just switched the default engine and NOT disabled the INNODB calls in my.ini, would that have prevented the problem? I restored all the MYISAM files and got everything back working again. I don't want to go through the lengthy reproduction exercise of reinstalling everything to test the theory so if someone has had some experience with this, I would appreciate hearing from them. -- Best regards, mikesz mailto:[EMAIL PROTECTED] -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED] -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
DROP TABLE IF EXISTS - doesnt??
I am finding that DROP TABLE IF EXISTS mytable; Works fine if the table exists - but if it doesn't exist I get an error? Surely it should not error and just not try to drop the table. Is it me?
REGEXP vs LIKE/OR
Hi, I want to retrieve all records where the field value contains either foo, bar or baz. Like so: SELECT id FROM table WHERE value LIKE '%foo%' OR value LIKE '%bar%' OR value LIKE '%baz%'; But then I stumbled upon REGEXP, and can do the same this way: SELECT id FROM table WHERE value REGEXP 'foo|bar|baz' != 0; Any opinions on what's the better approach and why? Thanks Morten -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
Re: DROP TABLE IF EXISTS - doesnt??
Hmmm. It works okay for me, without an error when the tabel doesn't exist. I'm using mysql Server version 5.0.51a-3ubuntu5.1 For example: * mysql use lsldatabase; Reading table information for completion of table and column names You can turn off this feature to get a quicker startup with -A Database changed mysql show tables; +---+ | Tables_in_lsldatabase | +---+ | lslstore | +---+ 1 row in set (0.00 sec) mysql drop table if exists recipes; Query OK, 0 rows affected, 1 warning (0.00 sec) * As you see, the table recipes doesn't already exist, and I don't get an error. roger.maynard wrote: I am finding that DROP TABLE IF EXISTS mytable; Works fine if the table exists - but if it doesn't exist I get an error? Surely it should not error and just not try to drop the table. Is it me? -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
Re: Need help to query with timestamp in C++
Kandy Wong wrote: Hi Saul, I need to use C++ and I'm not writing a web application. Thanks anyway. you can do something like: select min(abs(timediff(targettime,timestamp))) from table where condition ; if you use the libmysql you can get the result as strings back (the method i prefer) and convert them in what ever you need. re, wh The followings are the timestamp in the MySQL database: | 2008-08-05 03:56:09 | 1217933769 | | 2008-08-05 03:56:19 | 1217933779 | | 2008-08-05 03:56:29 | 1217933789 | | 2008-08-05 03:59:39 | 1217933979 | | 2008-08-05 03:59:49 | 1217933989 | | 2008-08-05 03:59:59 | 1217933999 | | 2008-08-05 04:02:39 | 1217934159 | | 2008-08-05 04:02:49 | 1217934169 | | 2008-08-05 04:02:59 | 1217934179 | For example, '2008-08-05 04:01:39' is the time provided by the user which does not exist in the database. So, how can I return the closest data? I know I can make use of 'LIKE' but this will return more than one data. What is the best method to get the closest one? And what is the good connector (C++ to MySQL) to use? Any suggestion? Thank you. Kandy -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED] -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
encode/decode question
Hi, One of our previous developers decided to obfuscate some columns via the mysql encode and decode functions. This was done on a 4.x server. Recently, we converted to a 5.x server, and some of the fields in the rows will not decode correctly, and I cannot figure out why. My first thought was that perhaps the implementation of encode/decode changed, but googling so far has been to no avail. My second thought was that perhaps there was a problem when we dumped the data from the 4.x server and imported it to the 5.x server. The old 4.x server is gone, so I cannot verify whether that is the case. I did dump/restore the data in question from the 5.x back to a 4.x server, but it decodes in error as well. This obfuscation was a retrofit to an existing table, mostly of varchar fields. Another thought I had was that perhaps it's not a good idea to store binary data in a varchar field. So, a few questions: Anyone know if the implementation of endcode/decode changed along the line from v4 to v5? What algorithm is used for encode/decode? Are there limits on what can be stored in a varchar field? Is it ok to store the results of encode/decode in a varchar? We don't need to encrypt the data, simply obfuscate it to prevent accidental, unintentional use. Any ideas appreciated. Thank you. Regards, Rich -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
Re: Need help to query with timestamp in C++
Kandy Wong wrote: And what is the good connector (C++ to MySQL) to use? MySQL++ (http://tangentsoft.net/mysql++/) has native Date, Time, and DateTime data types. You can convert to these types implicitly: mysqlpp::DateTime dt = row[my_column]; Row::operator[] doesn't return DateTime, it returns a stringish type, which can convert itself to lots of different C++ data types. This is useful because the MySQL C API normally returns results in string form, so you need a natural way to convert these values to the native C++ types for processing. In this particular case, it saves you from having to do the timestamp string parsing yourself. -- Warren Young, maintainer of MySQL++ -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
RE: Need help to query with timestamp in C++
I'm puzzled by the layout of your table, if that's what you're showing us. Is the timestamp in the table truly associated with the time at which the user put in his approximate time? If, for example, the user types in 04:05:07 at 04:03:02, and then types in 04:02:59 at 04:03:03, what is it that you want to return? Regards, Jerry Schwartz The Infoshop by Global Information Incorporated 195 Farmington Ave. Farmington, CT 06032 860.674.8796 / FAX: 860.674.8341 www.the-infoshop.com www.giiexpress.com www.etudes-marche.com -Original Message- From: Kandy Wong [mailto:[EMAIL PROTECTED] Sent: Friday, August 15, 2008 2:36 AM To: Saul Bejarano Cc: mysql@lists.mysql.com Subject: Re: Need help to query with timestamp in C++ Hi Saul, I need to use C++ and I'm not writing a web application. Thanks anyway. Kandy I have done queries to the database in PHP with variables like month but easily can select from a range of time and data to produce the same results, the output goes directly to the web so if that is what you are seeking for, I can help with PHP. Saul Kandy Wong wrote: Hi, I need to write a C++ program in a Linux environment to query with a timestamp. The user will only provide with an approximate time so I'd like to know how can I write a program or a query to return the closest data. The followings are the timestamp in the MySQL database: | 2008-08-05 03:56:09 | 1217933769 | | 2008-08-05 03:56:19 | 1217933779 | | 2008-08-05 03:56:29 | 1217933789 | | 2008-08-05 03:59:39 | 1217933979 | | 2008-08-05 03:59:49 | 1217933989 | | 2008-08-05 03:59:59 | 1217933999 | | 2008-08-05 04:02:39 | 1217934159 | | 2008-08-05 04:02:49 | 1217934169 | | 2008-08-05 04:02:59 | 1217934179 | For example, '2008-08-05 04:01:39' is the time provided by the user which does not exist in the database. So, how can I return the closest data? I know I can make use of 'LIKE' but this will return more than one data. What is the best method to get the closest one? And what is the good connector (C++ to MySQL) to use? Any suggestion? Thank you. Kandy -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED] -- Kandy Wong Scientific Programmer Analyst TRIUMF (Canada's National Laboratory for Particle and Nuclear Physics) 4004 Wesbrook Mall Vancouver, BC, Canada, V6T 2A3 Phone: (604) 222- 1047 ext. 6193 Email: [EMAIL PROTECTED] -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED] infoshop.com -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
RE: DROP TABLE IF EXISTS - doesnt??
I am getting this problem when I am calling this from within a stored procedure and from the command line area but from MySQLQueryBrowser Windows package. I have tried the DROP TABLE IF EXISTS from the mysql DOS-type command line and it doesn't error - I do notice that (also in your example) that there is a Warning provided. Maybe what I am seeing in the Query Browser area is in fact a Warning message and not an error!! If so, sorry to have wasted anyone's time Regards Roger -Original Message- From: Fish Kungfu [mailto:[EMAIL PROTECTED] Sent: 15 August 2008 12:43 To: mysql@lists.mysql.com Subject: Re: DROP TABLE IF EXISTS - doesnt?? Hmmm. It works okay for me, without an error when the tabel doesn't exist. I'm using mysql Server version 5.0.51a-3ubuntu5.1 For example: * mysql use lsldatabase; Reading table information for completion of table and column names You can turn off this feature to get a quicker startup with -A Database changed mysql show tables; +---+ | Tables_in_lsldatabase | +---+ | lslstore | +---+ 1 row in set (0.00 sec) mysql drop table if exists recipes; Query OK, 0 rows affected, 1 warning (0.00 sec) * As you see, the table recipes doesn't already exist, and I don't get an error. roger.maynard wrote: I am finding that DROP TABLE IF EXISTS mytable; Works fine if the table exists - but if it doesn't exist I get an error? Surely it should not error and just not try to drop the table. Is it me? -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED] -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
RE: DROP TABLE IF EXISTS - doesnt??
I am certain the SQLBrowser program authors want to hear about this error It may be due to the fact that MYSQL procedures need to have a different delimiter (//) instead of ; e.g. use DBNAME; DROP PROCEDURE IF EXISTS TABLE_NAME; delimiter //; Anyone? Martin __ Disclaimer and confidentiality note Everything in this e-mail and any attachments relates to the official business of Sender. This transmission is of a confidential nature and Sender does not endorse distribution to any party other than intended recipient. Sender does not necessarily endorse content contained within this transmission. Subject: RE: DROP TABLE IF EXISTS - doesnt?? Date: Fri, 15 Aug 2008 14:50:16 +0100 From: [EMAIL PROTECTED] To: mysql@lists.mysql.com I am getting this problem when I am calling this from within a stored procedure and from the command line area but from MySQLQueryBrowser Windows package. I have tried the DROP TABLE IF EXISTS from the mysql DOS-type command line and it doesn't error - I do notice that (also in your example) that there is a Warning provided. Maybe what I am seeing in the Query Browser area is in fact a Warning message and not an error!! If so, sorry to have wasted anyone's time Regards Roger -Original Message- From: Fish Kungfu [mailto:[EMAIL PROTECTED] Sent: 15 August 2008 12:43 To: mysql@lists.mysql.com Subject: Re: DROP TABLE IF EXISTS - doesnt?? Hmmm. It works okay for me, without an error when the tabel doesn't exist. I'm using mysql Server version 5.0.51a-3ubuntu5.1 For example: * mysql use lsldatabase; Reading table information for completion of table and column names You can turn off this feature to get a quicker startup with -A Database changed mysql show tables; +---+ | Tables_in_lsldatabase | +---+ | lslstore | +---+ 1 row in set (0.00 sec) mysql drop table if exists recipes; Query OK, 0 rows affected, 1 warning (0.00 sec) * As you see, the table recipes doesn't already exist, and I don't get an error. roger.maynard wrote: I am finding that DROP TABLE IF EXISTS mytable; Works fine if the table exists - but if it doesn't exist I get an error? Surely it should not error and just not try to drop the table. Is it me? -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED] -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED] _ Talk to your Yahoo! Friends via Windows Live Messenger. Find out how. http://www.windowslive.com/explore/messenger?ocid=TXT_TAGLM_WL_messenger_yahoo_082008
RE: DROP TABLE IF EXISTS - doesnt??
Maybe what I am seeing in the Query Browser area is in fact a Warning message and not an error!! Ahhh...yes maybe that's it. Just fyi, here is the detail of the warning: mysql drop table if exists recipes; Query OK, 0 rows affected, 1 warning (0.00 sec) mysql SHOW WARNINGS; +---+--+-+ | Level | Code | Message | +---+--+-+ | Note | 1051 | Unknown table 'recipes' | +---+--+-+ 1 row in set (0.00 sec) CheersFish --- ~~Second Life addict ~~ -Original Message- From: roger.maynard [EMAIL PROTECTED] Sent: Aug 15, 2008 9:50 AM To: mysql@lists.mysql.com Subject: RE: DROP TABLE IF EXISTS - doesnt?? I am getting this problem when I am calling this from within a stored procedure and from the command line area but from MySQLQueryBrowser Windows package. I have tried the DROP TABLE IF EXISTS from the mysql DOS-type command line and it doesn't error - I do notice that (also in your example) that there is a Warning provided. Maybe what I am seeing in the Query Browser area is in fact a Warning message and not an error!! If so, sorry to have wasted anyone's time Regards Roger -Original Message- From: Fish Kungfu [mailto:[EMAIL PROTECTED] Sent: 15 August 2008 12:43 To: mysql@lists.mysql.com Subject: Re: DROP TABLE IF EXISTS - doesnt?? Hmmm. It works okay for me, without an error when the tabel doesn't exist. I'm using mysql Server version 5.0.51a-3ubuntu5.1 For example: * mysql use lsldatabase; Reading table information for completion of table and column names You can turn off this feature to get a quicker startup with -A Database changed mysql show tables; +---+ | Tables_in_lsldatabase | +---+ | lslstore | +---+ 1 row in set (0.00 sec) mysql drop table if exists recipes; Query OK, 0 rows affected, 1 warning (0.00 sec) * As you see, the table recipes doesn't already exist, and I don't get an error. roger.maynard wrote: I am finding that DROP TABLE IF EXISTS mytable; Works fine if the table exists - but if it doesn't exist I get an error? Surely it should not error and just not try to drop the table. Is it me? -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED] -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED] -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
PHP Documentation in the MySQL Manual
PHP Documentation in the MySQL Manual - MySQL can be used with a multitude of programming languages, but PHP is probably the most popular choice. For that reason, we always felt a bit bad about our PHP-related documentation being somewhat sparse, mostly consisting of links to the PHP manual. Well, that situation has changed. MC Brown of the MySQL Docs team has moved over the MySQL-related parts of the PHP documentation to the MySQL Reference Manual now. You can find it here: http://dev.mysql.com/doc/refman/5.1/en/php.html No worries, we haven't actually *moved* the PHP docs. Rather than that, they're being synced over from php.net to our mysqldoc repository on a regular basis, where they get merged into the MySQL docs and built in various format (HTML, PDF, CHM, etc.) just like the rest of the documentation. This means users who work with MySQL and PHP don't have to flip between manuals any more, but can rather look up all information in one place. We regard this as another sign that MySQL has a strong commitment towards the PHP users in our community. Currently, the PHP docs cover: * ext/mysql (the original set of PHP functions for accessing MySQL) * ext/mysqli (the improved and recommended set of functions) * PDO_MYSQL (the MySQL PDO driver for PHP's PDO interface) This will soon be amended by the newest set of functions: * ext/mysqlnd Tony Bedford of the MySQL Docs team will be in charge of writing the new section on ext/mysqlnd. Currently, he's in the process of reworking the ext/mysqli section which still lacks a lot of function descriptions. When done with this, the MySQL-related parts of the PHP documentation will be in much better shape, so that's a true win-win situation for PHP and MySQL. Needless to say, Tony will keep maintaining the PHP docs, so they'll always be up to date, complete, and correct. Go MySQL! Go PHP! :-) Regards, Stefan -- *** Sun Microsystems GmbHStefan Hinz Sonnenallee 1Manager Documentation, Database Group 85551 Kirchheim-Heimstetten Phone: +49-30-82702940 Germany Fax: +49-30-82702941 http://www.sun.demailto: [EMAIL PROTECTED] Amtsgericht Muenchen: HRB161028 Geschaeftsfuehrer: Thomas Schroeder, Wolfgang Engels, Dr. Roland Boemer Vorsitzender des Aufsichtsrates: Martin Haering *** -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
RE: REGEXP vs LIKE/OR
It looks like LIKE is only slightly faster(on my XP), hardly worth mentioning. Go with what is easier for you to read or for portability if you need it. IMHO set @a='gfdueruie baz hdhrh';select BENCHMARK(500, (select 1 from dual WHERE @a LIKE '%foo%' OR @a LIKE '%bar%' OR @a LIKE '%baz%')) as elapse_time; # average 750ms set @a='gfdueruie baz hdhrh';select BENCHMARK(500, (select 1 from dual WHERE @a REGEXP 'foo|bar|baz' != 0)) as elapse_time; # average 770ms Ed -Original Message- From: Morten Primdahl [mailto:[EMAIL PROTECTED] Sent: Friday, August 15, 2008 5:12 AM To: mysql Subject: REGEXP vs LIKE/OR Hi, I want to retrieve all records where the field value contains either foo, bar or baz. Like so: SELECT id FROM table WHERE value LIKE '%foo%' OR value LIKE '%bar%' OR value LIKE '%baz%'; But then I stumbled upon REGEXP, and can do the same this way: SELECT id FROM table WHERE value REGEXP 'foo|bar|baz' != 0; Any opinions on what's the better approach and why? Thanks Morten -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED] -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
MySQL compatibility with Windows Server 2008
We will be purchasing a server pretty soon with Windows Server 2008 on it. I have heard that MySQL is not compatible with WS2008. Is that true? I've also seen instructions for installing MySQL 5.1 on WS2008. Is 5.1 compatible, but earlier versions are not? We run ASP and ASP.Net applications on our servers now, and the new server will be used for the same. So, what about the MySQL .Net connector and the ODBC Driver? Are they compatible with WS2008? Thanks, Jesse -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
Re: PHP Documentation in the MySQL Manual
HOORAY!!! Thanks for all of yours and Tony's hard work! CheersFish - ~~Second Life addict~~ -Original Message- From: Stefan Hinz [EMAIL PROTECTED] Sent: Aug 15, 2008 11:09 AM To: mysql@lists.mysql.com Subject: PHP Documentation in the MySQL Manual PHP Documentation in the MySQL Manual - MySQL can be used with a multitude of programming languages, but PHP is probably the most popular choice. For that reason, we always felt a bit bad about our PHP-related documentation being somewhat sparse, mostly consisting of links to the PHP manual. Well, that situation has changed. MC Brown of the MySQL Docs team has moved over the MySQL-related parts of the PHP documentation to the MySQL Reference Manual now. You can find it here: http://dev.mysql.com/doc/refman/5.1/en/php.html No worries, we haven't actually *moved* the PHP docs. Rather than that, they're being synced over from php.net to our mysqldoc repository on a regular basis, where they get merged into the MySQL docs and built in various format (HTML, PDF, CHM, etc.) just like the rest of the documentation. This means users who work with MySQL and PHP don't have to flip between manuals any more, but can rather look up all information in one place. We regard this as another sign that MySQL has a strong commitment towards the PHP users in our community. Currently, the PHP docs cover: * ext/mysql (the original set of PHP functions for accessing MySQL) * ext/mysqli (the improved and recommended set of functions) * PDO_MYSQL (the MySQL PDO driver for PHP's PDO interface) This will soon be amended by the newest set of functions: * ext/mysqlnd Tony Bedford of the MySQL Docs team will be in charge of writing the new section on ext/mysqlnd. Currently, he's in the process of reworking the ext/mysqli section which still lacks a lot of function descriptions. When done with this, the MySQL-related parts of the PHP documentation will be in much better shape, so that's a true win-win situation for PHP and MySQL. Needless to say, Tony will keep maintaining the PHP docs, so they'll always be up to date, complete, and correct. Go MySQL! Go PHP! :-) Regards, Stefan -- *** Sun Microsystems GmbHStefan Hinz Sonnenallee 1Manager Documentation, Database Group 85551 Kirchheim-Heimstetten Phone: +49-30-82702940 Germany Fax: +49-30-82702941 http://www.sun.demailto: [EMAIL PROTECTED] Amtsgericht Muenchen: HRB161028 Geschaeftsfuehrer: Thomas Schroeder, Wolfgang Engels, Dr. Roland Boemer Vorsitzender des Aufsichtsrates: Martin Haering *** -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED] -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
Re: Need help to query with timestamp in C++
Hi Dusan, Thank you so much. It works! Kandy Hi Kandy, this could be the query you are looking for. It should return record with the closest timestamp to your required time: (SELECT TIMEDIFF('20080815091907', timestamp_column) AS diff, t.* FROM table1 t WHERE timestamp_column = '20080815091907' ORDER BY timestamp_column DESC LIMIT 1 ) UNION (SELECT TIMEDIFF(timestamp_column, '20080815091907') AS diff, t.* FROM table1 t WHERE timestamp_column = '20080815091907' ORDER BY timestamp_column LIMIT 1 ) ORDER BY diff LIMIT 1 HTH, Dusan Kandy Wong napsal(a): Hi, I need to write a C++ program in a Linux environment to query with a timestamp. The user will only provide with an approximate time so I'd like to know how can I write a program or a query to return the closest data. The followings are the timestamp in the MySQL database: | 2008-08-05 03:56:09 | 1217933769 | | 2008-08-05 03:56:19 | 1217933779 | | 2008-08-05 03:56:29 | 1217933789 | | 2008-08-05 03:59:39 | 1217933979 | | 2008-08-05 03:59:49 | 1217933989 | | 2008-08-05 03:59:59 | 1217933999 | | 2008-08-05 04:02:39 | 1217934159 | | 2008-08-05 04:02:49 | 1217934169 | | 2008-08-05 04:02:59 | 1217934179 | For example, '2008-08-05 04:01:39' is the time provided by the user which does not exist in the database. So, how can I return the closest data? I know I can make use of 'LIKE' but this will return more than one data. What is the best method to get the closest one? And what is the good connector (C++ to MySQL) to use? Any suggestion? Thank you. Kandy -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
Re: MySQL compatibility with Windows Server 2008
.NET connector is fine. ODBC should be ok but I'm not 100% sure. Jesse wrote: We will be purchasing a server pretty soon with Windows Server 2008 on it. I have heard that MySQL is not compatible with WS2008. Is that true? I've also seen instructions for installing MySQL 5.1 on WS2008. Is 5.1 compatible, but earlier versions are not? We run ASP and ASP.Net applications on our servers now, and the new server will be used for the same. So, what about the MySQL .Net connector and the ODBC Driver? Are they compatible with WS2008? Thanks, Jesse -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
Re: MySQL compatibility with Windows Server 2008
.NET connector is fine. ODBC should be ok but I'm not 100% sure. How about MySQL itself? Thanks, Jesse -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
Re: MySQL compatibility with Windows Server 2008
It can depend on the version. Earlier versions of MySQL had problems with protocols like shared memory on Vista. Use a recent build of 5.0 or 5.1 and you should be ok. Jesse wrote: .NET connector is fine. ODBC should be ok but I'm not 100% sure. How about MySQL itself? Thanks, Jesse -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
Re: MYSQL PROCESS
Can you give us the output of `uname -a` from your mysql hosts? There's a difference if you are running a 2.4 kernel vs. 2.6 kernel (Linux). In 2.4 kernel, try ps -ef, and in 2.6 kernel, ps -Lef. You may notice that PPID is the same for all PIDs except one, usually. -Paul On Thu, 2008-08-14 at 13:38 +0530, Krishna Chandra Prajapati wrote: But some of the mysql server(mysql server on debian) shows only one mysql process. On Thu, Aug 14, 2008 at 12:56 PM, Ellison, David [EMAIL PROTECTED] wrote: I may be talking rubbish here, but is it not threading? I have seen Linux processes before create more than one PID etc when it needs to handle multiple requests. This may be not true for MySQL. However when looking at my test server is shows more than one. If you use a command called htop, similar to top but a little more visually easier, it has an option called tree. Which shows how one process spawns many when/where needed. Dave -Original Message- From: Krishna Chandra Prajapati [mailto:[EMAIL PROTECTED] Sent: 14 August 2008 05:57 To: mysql Subject: MYSQL PROCESS Hi all, I am running mysql on debian. I didn't understand why there is a lots of mysql process running. There should be only one mysql process running. Please help me that what should i do. Although there is no problem with mysql server. debian:~# ps axu USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND root 1 0.0 0.0 1400 472 ?SJun03 0:03 init [2] root 2 0.0 0.0 00 ?SJun03 0:01 [keventd] root 3 0.0 0.0 00 ?SN Jun03 0:06 [ksoftirqd_CPU0] root 4 0.0 0.0 00 ?SJun03 2:25 [kswapd] root 5 0.0 0.0 00 ?SJun03 0:00 [bdflush] root 6 0.0 0.0 00 ?SJun03 1:15 [kupdated] root99 0.0 0.0 00 ?SJun03 6:52 [kjournald] root 250 0.0 0.0 00 ?SJun03 0:00 [kcopyd] root 252 0.0 0.0 00 ?SJun03 0:00 [kmirrord] root 265 0.0 0.0 00 ?SJun03 0:00 [kjournald] root 431 0.0 0.0 00 ?SJun03 0:00 [khubd] root 1247 0.0 0.0 1456 600 ?Ss Jun03 0:04 /sbin/syslogd root 1250 0.0 0.0 2084 444 ?Ss Jun03 0:00 /sbin/klogd root 1288 0.0 0.1 2432 1024 ?SJun03 0:00 /bin/sh /usr/bin/mysqld_safe mysql 1325 0.0 27.1 324124 262548 ? SJun03 0:31 /usr/sbin/mysqld --basedir=/usr --datadir=/var/ mysql 1336 0.0 27.1 324124 262548 ? SJun03 0:03 /usr/sbin/mysqld --basedir=/usr --datadir=/var/ mysql 1337 0.0 27.1 324124 262548 ? SJun03 0:00 /usr/sbin/mysqld --basedir=/usr --datadir=/var/ mysql 1338 0.0 27.1 324124 262548 ? SJun03 0:01 /usr/sbin/mysqld --basedir=/usr --datadir=/var/ mysql 1339 0.0 27.1 324124 262548 ? SJun03 16:49 /usr/sbin/mysqld --basedir=/usr --datadir=/var/ mysql 1340 0.0 27.1 324124 262548 ? SJun03 0:30 /usr/sbin/mysqld --basedir=/usr --datadir=/var/ mysql 1369 0.0 27.1 324124 262548 ? SJun03 6:10 /usr/sbin/mysqld --basedir=/usr --datadir=/var/ mysql 1370 0.0 27.1 324124 262548 ? SJun03 3:32 /usr/sbin/mysqld --basedir=/usr --datadir=/var/ mysql 1380 0.0 27.1 324124 262548 ? SJun03 1:16 /usr/sbin/mysqld --basedir=/usr --datadir=/var/ mysql 1381 0.0 27.1 324124 262548 ? SJun03 0:08 /usr/sbin/mysqld --basedir=/usr --datadir=/var/ mysql 1384 0.0 27.1 324124 262548 ? SJun03 5:33 /usr/sbin/mysqld --basedir=/usr --datadir=/var/ root 1431 0.0 0.1 4736 1560 ?Ss Jun03 1:23 /usr/sbin/sshd . . . .. . mysql 3404 0.0 27.1 324124 262548 ? SJun04 3:22 /usr/sbin/mysqld --basedir=/usr --datadir=/var/ mysql 3456 0.0 27.1 324124 262548 ? SJun04 3:06 /usr/sbin/mysqld --basedir=/usr --datadir=/var/ mysql 3607 0.0 27.1 324124 262548 ? SJun04 3:24 /usr/sbin/mysqld --basedir=/usr --datadir=/var/ mysql 3685 0.0 27.1 324124 262548 ? SJun04 2:25 /usr/sbin/mysqld --basedir=/usr --datadir=/var/ mysql 5325 0.0 27.1 324124 262548 ? SJun05 3:14 /usr/sbin/mysqld --basedir=/usr --datadir=/var/ mysql 5352 0.0 27.1 324124 262548 ? SJun05 3:21 /usr/sbin/mysqld --basedir=/usr --datadir=/var/ mysql 5374 0.0 27.1 324124 262548 ? SJun05 3:16 /usr/sbin/mysqld --basedir=/usr --datadir=/var/ mysql 5378 0.0 27.1 324124 262548 ? SJun05 3:06 /usr/sbin/mysqld --basedir=/usr --datadir=/var/ mysql 5397 0.0 27.1 324124 262548 ? SJun05 2:49 /usr/sbin/mysqld --basedir=/usr --datadir=/var/ mysql 5398 0.0