List Info

Thread: Newbie question about UNIQUE MySQL v5.0.22




Newbie question about UNIQUE MySQL v5.0.22
user name
2007-07-16 13:25:05
Hi all,

I need some help...

My Example:

Field: Bank Account Nš: 12353545456 &  Field: Bank
Account Nš: (Empty)

The nš must be unique but could be empty also...

What is the SQL? It's Possible?


Best Regards
PiRiCa


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "PHP-Masters" group.
To post to this group, send email to PHP-Mastersgooglegroups.com
To unsubscribe from this group, send email to
PHP-Masters-unsubscribegooglegroups.com
For more options, visit this group at http://gro
ups.google.com/group/PHP-Masters
-~----------~----~----~----~------~----~------~--~---


Re: Newbie question about UNIQUE MySQL v5.0.22
user name
2007-07-16 17:54:17
What are you asking?

On 7/16/07, nelson.salvadorgmail.com">nelson.salvadorgmail.com < nelson.salvadorgmail.com"> nelson.salvadorgmail.com> wrote:

Hi all,

I need some help...

My Example:

Field: Bank Account Nš: 12353545456 & ; Field: Bank Account Nš: (Empty)

The nš must be unique but could be empty also...

What is the SQL? It's Possible?


Best Regards
PiRiCa




-Jhecht
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "PHP-Masters&quot; group.
To post to this group, send email to PHP-Mastersgooglegroups.com
To unsubscribe from this group, send email to PHP-Masters-unsubscribegooglegroups.com
For more options, visit this group at http://groups.google.com/group/PHP-Masters
-~----------~----~----~----~------~----~------~--~---

Re: Newbie question about UNIQUE MySQL v5.0.22
user name
2007-07-17 04:29:56
if you're looking for a distinct list of account numbers
from the
table, the starting point would be:
SELECT DISTINCT <ACCOUNT_NUMBER> FROM
<BANK_ACCOUNT>;
where <ACCOUNT_NUMBER> is the account number field and
<BANK_ACCOUNT>
is the name of the table.


On Jul 16, 8:25 pm, "nelson.salva...gmail.com"
<nelson.salva...gmail.com> wrote:
> Hi all,
>
> I need some help...
>
> My Example:
>
> Field: Bank Account Nš: 12353545456 &  Field: Bank
Account Nš: (Empty)
>
> The nš must be unique but could be empty also...
>
> What is the SQL? It's Possible?
>
> Best Regards
> PiRiCa


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "PHP-Masters" group.
To post to this group, send email to PHP-Mastersgooglegroups.com
To unsubscribe from this group, send email to
PHP-Masters-unsubscribegooglegroups.com
For more options, visit this group at http://gro
ups.google.com/group/PHP-Masters
-~----------~----~----~----~------~----~------~--~---


Re: Newbie question about UNIQUE MySQL v5.0.22
user name
2007-07-20 18:40:11
Many Thanks!!


I have my code working now!


Unique field: ncheque
If emply will be NULL value


PHP:


if($_POST["titular"]!="" &&
$_POST["valorcheque"]!="" &&
$_POST["banco"]!="" &&
$_POST["datavencimento"]!=""){
                $tipo_pagamento =
$_POST["tipo_pagamento"];
                $ncheque = $_POST["ncheque"];
            $ncheque = ($ncheque != "") ?
"'" . $ncheque . "'" :
"NULL";
                $titular = $_POST["titular"];
                $valorcheque =
virgulatoponto($_POST["valorcheque"]);
                $banco = $_POST["banco"];
                $vencimento =
datatobanco($_POST["datavencimento"]);
                $cidadeorigem =
$_POST["cidadeorigem"];
                $notas = $_POST["notas"];
                $recibo = $_POST["recibo"];
                $compra = $_POST["compra"];
                $data = date("Y-m-d");
                $db = new Database();
                $db->query("Insert into pagamentos
(tipo_pagamento,titular,ncheque,vencimento,valor,datacadastr
o,banco,cidadeo--
rigem,notas,recibo,compra)
values ('$tipo_pagamento','$titular',
$ncheque,'$vencimento','$valorcheque','$data','$banco','$cid
adeorigem','$no--
tas','$recibo','$compra')");
        }


SQL:
CREATE TABLE `pagamentos` (
  `ID` int(6) NOT NULL auto_increment,
  `tipo_pagamento` varchar(12) default NULL,
  `titular` varchar(80) default NULL,
  `ncheque` varchar(10) default NULL,
  `valor` float(10,2) default NULL,
  `vencimento` date default NULL,
  `datacadastro` date default NULL,
  `banco` tinyint(6) default NULL,
  `cidadeorigem` varchar(60) default NULL,
  `notas` longtext,
  `recibo` varchar(20) default NULL,
  `compra` longtext,
  PRIMARY KEY  (`ID`),
  UNIQUE KEY `ncheque` (`ncheque`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1;


Best Regards,
PiRiCa


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "PHP-Masters" group.
To post to this group, send email to PHP-Mastersgooglegroups.com
To unsubscribe from this group, send email to
PHP-Masters-unsubscribegooglegroups.com
For more options, visit this group at http://gro
ups.google.com/group/PHP-Masters
-~----------~----~----~----~------~----~------~--~---


[1-4]

about | contact  Other archives ( Real Estate discussion Medical topics )