Questions tagged [mysql-select-db]

66 questions
8
votes
2 answers

Can you reuse a mysql result set in PHP?

I have a result set I pull from a large database: $result = mysql_query($sql); I loop through this recordset once to pull specific bits of data and get averages using while($row = mysql_fetch_array($result)). Later in the page, I want to loop…
MarathonStudios
  • 3,261
  • 10
  • 37
  • 44
5
votes
5 answers

How can I select the last edited version of a post?

Here is the table structure: +----+-----------------------------+-----------+ | id | post_content | edited_id | +----+-----------------------------+-----------+ | 1 | content 1 | NULL | | 2 | content 2 …
Martin AJ
  • 5,313
  • 4
  • 32
  • 79
3
votes
5 answers

How to insert data in two different tables of two different database in php

I have to insert data in two different database's table. I have created database1 and table1 for database1, also i have created database2 and table2 for database2. For inserting data i have written code, $connect =…
M Gaidhane
  • 530
  • 8
  • 28
2
votes
4 answers

Insert query depend on another table

Below are MySQL tables. I need to insert values from table A's ID column to Table B's ID_A column. Already existed values in ID_A should be ignored. So that in the below mentioned example IDs 1 to 3 from Table A should be ignored and IDs 4 to 10…
Kaizar Laxmidhar
  • 799
  • 15
  • 37
2
votes
2 answers

"mysql_select_db" fails while "mysql_connect" OK

new here, only starting basic PHP. Trying to understand the specifics of the two MySQL commands. Please see this code
Andrejs
  • 8,412
  • 4
  • 38
  • 42
2
votes
3 answers

how to select MAX(updateTag)

I create digiCardPass with updateTag column that is timestamp. I try: $query1 = mysql_query("select MAX(updateTag) as updateTag from digiCardPass"); $row1 = mysql_fetch_array($query1); $updateTag = $row1['updateTag']; error_log("max…
malinchhan
  • 717
  • 1
  • 8
  • 25
1
vote
1 answer

Need to Create MySQL Procedure for getting data from table based on condition and insert them into another table

Using a single MySQL procedure i need to write queries to get data from a table (where the results can be of a list also) after getting the results,need to insert those selected rows into another table of the same database..I'm finding dificulty in…
reema
  • 19
  • 6
1
vote
2 answers

What is the best approach to getting the last x records? Using MySQL Limit and ORDER DESC?

I was wondering if there are any other best/better practices then this as far as performance or optimizations. EDIT: I'm using PHP7. Should have made that clear, I apologize. I'm doing a volunteer project for a local non-profit and it's setup like…
BluTiger
  • 17
  • 7
1
vote
1 answer

How to add new column in select statement

i want to add new column in my select statement SELECT…
1
vote
1 answer

MySql Distinct Issues: Error Code: 1242 Subquery returns more than 1 row

I want to select distinct of apps_user.imeino My current SQL Query: SELECT app.name,app.emailid,app.mobileno,app.imeino,img.id,img.approve_status,img.path FROM apps_user app, apps_userimage img WHERE ((SELECT DISTINCT apps_user.imeino FROM…
1
vote
1 answer

Show result of MYSQL select query in two div according to column name, using a single select query

I have a table with column names id, name, category, title,and news. Once select query executes I get all the required data from table but i need to split up this data into two div according to the category they belong. there are two different…
munna ss
  • 186
  • 1
  • 2
  • 11
1
vote
4 answers

php mysql_select_db parameter 2 not working

I have the following code for test, and I just found the 2nd parameter is not actually working. $conn1 = mysql_connect("127.0.0.1", "xxxx", "xxxx"); $conn2 = mysql_connect("127.0.0.1", "xxxx", "xxxx"); mysql_select_db("test",…
Chenglu
  • 1,005
  • 11
  • 20
1
vote
6 answers

MYSQL - select TABLE A rows that are not in Table B except the rows are in TABLE C

TABLE A: dvdID.......dvdTitle d01..........Avenger d02..........Avenger d03..........Spiderman TABLE B: rentID.......dvdID r01...........d01 r02...........d02 r03...........d03 TABLE C: returnID.......rentID t01...............r01 i want to…
Altiano Gerung
  • 742
  • 2
  • 13
  • 27
1
vote
2 answers

MYSQL - How to UPDATE after SELECT from a table

i want to UPDATE the a column after i SELECT a table SELECT id_copies, id_shop, id_dvd FROM dvd_copies WHERE id_dvd = '001-192.168.1.103-6' AND id_shop='002' ORDER BY id_copies DESC LIMIT 2; i got just 2 rows that i want to be updated how can i…
Altiano Gerung
  • 742
  • 2
  • 13
  • 27
1
vote
2 answers

MySQL query with group contact

Let's say I have a table called "test" with the following design: SELECT type, name, `key` FROM test type | name | key ------------------------ 0 | maria | 123 1 | gabriel | 455 0 | rihanna | 69 1 | chris | 7 1 | martin |…
user1161005
1
2 3 4 5