0

Hello,
So here is the story:

I'm trying to select from two diferend tables ( bank_wire and visa)

CREATE TABLE IF NOT EXISTS `bank_wire` (
  `id` smallint(6) NOT NULL AUTO_INCREMENT,
  `method_name` char(255) COLLATE utf8_unicode_ci NOT NULL DEFAULT 'Bank wire',
  `checked` smallint(1) unsigned NOT NULL DEFAULT '1',
  `commision` char(255) COLLATE utf8_unicode_ci NOT NULL DEFAULT 'No commisions',
  `proccess_time` char(255) COLLATE utf8_unicode_ci NOT NULL DEFAULT 'Instant',
  `min_deposit` char(255) COLLATE utf8_unicode_ci NOT NULL DEFAULT '100 USD',
  `max_deposit` char(255) COLLATE utf8_unicode_ci NOT NULL DEFAULT 'No limits',
  PRIMARY KEY (`id`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=3 ;

--
-- Dump dei dati per la tabella `bank_wire`
--

INSERT INTO `bank_wire` (`id`, `method_name`, `checked`, `commision`, `proccess_time`, `min_deposit`, `max_deposit`) VALUES
(1, 'Bank wire', 1, 'No commisions', 'Instant', '100 USD', 'No limits'),
(2, 'Bank wire 2', 1, 'No commisions', 'Instant', '100 USD', 'No limits');

AND visa TABLE is this equal to bank_wire

CREATE TABLE IF NOT EXISTS `bank_wire` (
  `id` smallint(6) NOT NULL AUTO_INCREMENT,
  `method_name` char(255) COLLATE utf8_unicode_ci NOT NULL DEFAULT 'Bank wire',
  `checked` smallint(1) unsigned NOT NULL DEFAULT '1',
  `commision` char(255) COLLATE utf8_unicode_ci NOT NULL DEFAULT 'No commisions',
  `proccess_time` char(255) COLLATE utf8_unicode_ci NOT NULL DEFAULT 'Instant',
  `min_deposit` char(255) COLLATE utf8_unicode_ci NOT NULL DEFAULT '100 USD',
  `max_deposit` char(255) COLLATE utf8_unicode_ci NOT NULL DEFAULT 'No limits',
  PRIMARY KEY (`id`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=3 ;

--
-- Dump dei dati per la tabella `bank_wire`
--

INSERT INTO `bank_wire` (`id`, `method_name`, `checked`, `commision`, `proccess_time`, `min_deposit`, `max_deposit`) VALUES
(1, 'Bank wire', 1, 'No commisions', 'Instant', '100 USD', 'No limits'),
(2, 'Bank wire 2', 1, 'No commisions', 'Instant', '100 USD', 'No limits');

By now i have this php code to select 1 table :

<?php
include '../update/db.php';

$sql = "SELECT *  FROM bank_wire WHERE id =1 and  checked =1  ORDER by id ASC ";
$result = mysql_query($sql) or trigger_error(mysql_error(),E_USER_ERROR);
while($row = mysql_fetch_array($result)){

echo "<tr><td>";
 echo $row['method_name'];
echo "</td>";
echo "<td>";
 echo $row['commision'];
echo "</td>";
echo "<td>";
 echo $row['proccess_time'];
echo "</td>";
echo "<td>";
 echo $row['min_deposit'];
echo "</td>";
echo "<td>";
 echo $row['max_deposit'];
echo "</td></tr>\n";
}
?>

Here goes the question:

Q:| How do i select from two tables where checked =1 and id=1 ?

Thanks..

3
Contributors
3
Replies
7
Views
7 Years
Discussion Span
Last Post by artvor
0

Depends on the result you are looking for

SELECT * FROM bank_wire bw, visa v WHERE bw.id = 1 AND bw.id = v.id AND bw.checked = 1 AND v.checked = 1

//or

SELECT * FROM bank_wire WHERE id=1 AND checked=1
UNION
SELECT * FROM visa WHERE id=1 AND checked=1
0

Both tables have same name bank_wire. There is no table having name visa.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.