Programming :: Change A Mysql Query Result Prior To Display?
Oct 17, 2010
I am not sure if this is possible. I have IP's stored in a mysql database. When I query the database, it returns the IP. I would like to replace the IP with something else prior to displaying the results. Is it possible even though I have not stored it in the database?
I have the following in a while loop (mysql_fetch_array).
Code:
<td align="left">' . $row[IP] . '</td>
Instead of displaying $row[IP] from the database, I would like it to display something else which I define in the PHP code but based on the IP.
It is under PHP/MySQL $queryresult = $conn->query("INSERT INTO normalrequests VALUES($finalkey, 1234, 5678, FALSE)"); It is connected to the database successfully but I feel there is something wrong with the statement up there.
I have created a database which stores students grades for different stages of a project. One of the stages of the project is the specification part. I have a simple bit of html code which is going to be used as the searching facility. I want the user to be able to enter their ID and then it will display only their results. At the moment, it is displaying the results for EVERY student because I cant seem to find the correct syntax for my statement.
Trying to export a Mysql query to a .csv file the query draws from multiple tables, e.g. sales, purchase and currency
Code:
What i'm trying to do is to export both the sales and purchase to a single line where both the currency for the sales and the purchase is specified.
Basically like this:
Code:
Problem here is that i'm stating currency.value twice in the same select and don't know how to define which currency.value applies to sales and which to purchase.
i will be quick, im trying to send a mysql query output into an array ie:
Code: declare -a HD HD=`echo "USE db; SELECT uid FROM user" | mysql -u $login -p$pwd -h $dbhost -B` echo ${#HD} those vars in mysql connection are previously and correctly assigned. but got an error
I am querying a single string column in a table. The string values have spaces in them. I want to loop over each value in bash. I set IFS to split lists on newlines instead of spaces. When I try this, it is splitting the list of results on the actual character 'n', not the newline ''.
DATA=`mysql -u root -ppassword --silent 'SELECT name FROM table_a;'` IFS=$' ' for i in $DATA; do echo "item = $i"
So I've got a rather vast database, one of the columns is date in the following format: DD/MM/YY HH:MM:SS. This is starting to cause problems with a php page I'm writing which asks the user for a 'start date'. Would it be better for me to split the date column into date and say time? Or is there a way of using distinct and masking the times.
I am connecting to MySQL DataBase using shellscript and writing a select statement like select attachmentid from attachments where pageid=10175 I want to store the output of the select statement into a shellvariable or a file. How can i do it using shellscript.
I've tried to use workbench but it's such a big step backwards in that you can't easily edit the output from a "select x,y,z from table" query. I'd have thought that was a pretty basic requirement...
I have the following mysql query which works great.
Code: SELECT msg FROM `logs` WHERE ((`host` = 'aaa.bbb.ccc.ddd') OR (`host` = 'aaa.bbb.ccc.ddd')) AND `msg` REGEXP CONVERT( _utf8 'physical addresses' USING latin1 ) COLLATE latin1_swedish_ci I need to refine this query so that I can query the last # hours using the `datetime` field in the database. I have researched the DATE_SUB function and can query for example the last 1 hour like this:
I am on a CentOS 64 bit and used webmin to rotate MySQL slow query log. Now the thing is although logs are being rotated daily but the new log files being created are empty which means MySQL is unable to write them due to some reason. I have checked using "ls -l" that both permission and owner of files is same but still MySQL is not writing logs. What could be the reason?
i have MySQL on my CentOS server and have installed it and got it up and running through the command line.
I have changed root's username and password so there is no user called 'root' anymore. I also created a database called pancakes.Now when i try to log in using Query Browser, i put the server's IP in 'hostname', my new roots username and password in 'username' and 'password'.When i try to log in it gives me error 1130 and says connection from myhostname not allowed.
I am using MySQL 5.0.77 Version rpm on CentOS 5 Red Hat Linux. I want to install micro second slow query log patch on this MySQL S/W version.As I found the slow query micro second patch on percona site i.e. [URL]step by step to install above mentioned patch with rpm based MySQL installation? Do we need MySQL source files to apply patch ?
I would like to insert prior to the word "three" all items from this second file with the following contents:
Code:
four three two one
Now my issue is, and I have been using both sed and awk currently, that after the second line of the new file is read there will of course now be 2 copies of the word "three" but I would like to only insert the final 2 words, ie "two" and "one" prior to only the first occurrence of the word "three" so final file will look like:
Code:
one two four
[code]....
So here there is now only one of each word from the second file joined to make the new file. For simple code I have tried something like the following:
Code:
while read line do awk -v n=$line '!f && /three/{print n;f++}1' file1 > tmp_file mv tmp_file file1 done < file2
Now this works but seems very clumsy to me. There is obviously a better sed and / or awk out there.
I am running Ubuntu 10.04 LTS. I am trying to run a query browser for mysql but keep receiving the following error:
X11 connection rejected because of wrong authentication.
The application 'mysql-query-browser-bin' lost its connection to the display localhost:10.0; most likely the X server was shut down or you killed/destroyed the application.
I need help about the error in my website. I have the following error....
Code: user warning: Got error 134 from storage engine query: SELECT data, created, headers, expire, serialized FROM cache WHERE cid = 'theme_registry:database1' in /var/www/html/web/includes/cache.inc on line 26.
Quote: select * from s_transaction Where between UNIX_TIMESTAMP('2010-06-28 15:40:00') and UNIX_TIMESTAMP('2010-06-28 16:00:00') and user_id = '15545941';
Is this the syntax correct to retrieve a particular user transaction between given time period? because "its return error check the syntax near the between"
I wanted to get the ORACLE_HOME of the listener's running on the server.I have been using the following to get the reult. /opt/oracle/admin/PHYPE/bdump> ps -ef|grep /bin/tnslsnr|grep -v grep|awk '{print $9}'
I have a variable (call it $valAS) that gets calculated . Also, i have a files Bassu3. if $valAS= 45368 (2nd part of 2nd line in Bassu3) after calculation, then $result=45368, but if $valAS != 45368 then $result= $valAS
Bassu3:
Quote:
name.srv name 45368 (value always changing) name 99999 name 88888
I'm using the following awk command to find out the users home directory from /etc/passwd file.#grep jeesun /etc/passwd |awk 'BEGIN {FS=":"};{print $6}'But problem is when there are two name like "jeesun" and "jeesunadm" exist the script shows both result not specific one.
There is a protocol in use - for example when I use Firefox to do a query through Google - as I type into the search field the browser sends my characters - one at a time - to the server. As I recall, at one time I found the specification but I'm pulling a blank. As I recall it does a POST of each character as I enter it, and the server responds before I have entered a <CR>. I want to write a client side program that uses that protocol and need to see the spec.
What is the code snippet required to get an image to repeat vertically up a page? I can only find info relating to repeating *background* images in my search attempts, and this is just a regular image file which I want to repeat over the pre-existing page background. I'd like it to repeat all the way up the extreme left hand edge of the page. Say the image is called abd.jpg and is in the same folder as the index.html.
I'm trying to create a program that would locate the oldest file of a certain type on a server. Here's the commands:
OLDEST_PATH=`find -L / -depth -maxdepth 6 -mindepth 6 -type d | sort -f | head -1` OLDEST_FILE=`find -L $OLDEST_PATH | grep .mp3 | sort -f | head -1` ls -al $OLDEST_FILE
I'm writing this all in expect but I'm having problems. The main problem I have is whenever I try to run the first command, I can't seem to isolate the result of the OLDEST_PATH so that the 2nd command will work. There always seems to be a newline in the variable and the result is only "find -L" command running and it bypasses the variable. If I can just figure out how to get the 1st and 2nd command to work, then I can figure out the 3rd. Here's some code:
I know there is a better way to write this. I've tried multiple ways and this just happens to be the last way I've tried it. If you try running this, you'll notice that there is still carriage returns after the result of OLDEST_PATH and it prevents the 2nd "find" command from working properly.