Leandro H Mendes
Membros-
Total de itens
7 -
Registro em
-
Última visita
Tudo que Leandro H Mendes postou
-
Boa tarde tenho um cadastro de produtos tenho as seguintes tabelas produtos tecidos tamanhos produtos_tecidos(relacionamento) tecidos_tamanhos(relacionamento) eu preciso mostrar quais tecidos e seus respectivos tamanhos que um produto tem mais sem repitir nem o nome do tecido nem o tamanhos meu sql está assim e o resultado produzido por ela fica assim tecido / tamanho Turin - 10x15 Turin - 10x20 Turin - 30x 20 Genova - 10x15 Genova - 10x20 e meu cliente quer que fique assim Turin Genova - 10x15 - 10x20 Turin - 30x20 espero que alguém possa me ajudar obrigado
-
Select direto no Mysql com if else
pergunta respondeu ao Leandro H Mendes de Leandro H Mendes em MySQL
nome____________________estoque_fiscal___valor unitario____ subtotal Carteira Masculina ____________24 ____________ 0.60 ____________14.40 Casaco de Moleton____________5 ____________37.70____________188.50 Valor total 202.90 meu problema esta no valor unitario tenho que pegar ele na tabela nfiscal e se não encontrar pegar na tabela produto depois multiplicar pelo estoque pra chagar no subtotal e depois fazer a soma dos subtotal -
Select direto no Mysql com if else
pergunta respondeu ao Leandro H Mendes de Leandro H Mendes em MySQL
CREATE TABLE /*!32312 IF NOT EXISTS*/ `mi_itens_nfiscal` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `tipo_nota` int(10) unsigned DEFAULT '1', `idNota` int(10) unsigned DEFAULT NULL, `codigo` char(60) DEFAULT NULL, `ref` char(60) DEFAULT NULL, `descricao` char(120) DEFAULT NULL, `ean` char(14) DEFAULT NULL, `ncm` char(8) DEFAULT NULL, `ex_tipi` char(3) DEFAULT NULL, `cfop` char(4) DEFAULT NULL, `genero` char(2) DEFAULT NULL, `u_comercial` char(6) DEFAULT NULL, `q_comercial` float unsigned DEFAULT '0', `v_comercial` float unsigned DEFAULT '0', `u_tributavel` char(6) DEFAULT NULL, `q_tributavel` float unsigned DEFAULT '0', `v_tributavel` float unsigned DEFAULT '0', `ean_tributavel` char(14) DEFAULT NULL, `total_frete` float unsigned DEFAULT '0', `total_seguro` float unsigned DEFAULT '0', `desconto` float unsigned DEFAULT '0', `valor_total_bruto` float unsigned DEFAULT '0', `st` char(3) DEFAULT NULL, `origem` int(1) unsigned DEFAULT NULL, `modBC` int(1) unsigned DEFAULT NULL, `vBC` float unsigned DEFAULT '0', `pRedBC` float unsigned DEFAULT '0', `pICMS` float unsigned DEFAULT '0', `vICMS` float unsigned DEFAULT '0', `modBCST` int(1) unsigned DEFAULT NULL, `pMVAST` float unsigned DEFAULT '0', `pRedBCST` float unsigned DEFAULT '0', `vBCST` float unsigned DEFAULT '0', `pICMSST` float unsigned DEFAULT '0', `vICMSST` float unsigned DEFAULT '0', `pIPI` float unsigned DEFAULT '0', `vIPI` float unsigned DEFAULT '0', PRIMARY KEY (`id`) ) ENGINE=InnoDB AUTO_INCREMENT=14388 DEFAULT CHARSET=latin1; CREATE TABLE /*!32312 IF NOT EXISTS*/ `mi_produtos` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `id_fornecedor` int(10) unsigned DEFAULT NULL, `ref` varchar(50) DEFAULT NULL, `nome` varchar(100) DEFAULT NULL, `nome_fiscal` varchar(100) DEFAULT NULL, `descricao` longtext, `imagem` varchar(100) DEFAULT NULL, `codigo` varchar(50) DEFAULT NULL, `familia` varchar(100) DEFAULT NULL, `grupo` char(250) DEFAULT NULL, `cor` varchar(50) DEFAULT NULL, `tamanho` varchar(50) DEFAULT NULL, `fabricante` varchar(100) DEFAULT NULL, `tipo_cod_barra` char(1) DEFAULT 's', `cod_barra` varchar(50) DEFAULT NULL, `estoque` int(10) unsigned DEFAULT '10000', `estoque_minimo` int(10) unsigned DEFAULT '0', `estoque_maximo` int(10) unsigned DEFAULT '0', `estoque_seguranca` int(10) unsigned DEFAULT '0', `estoque_fiscal` int(10) unsigned DEFAULT '0', `setor` varchar(20) DEFAULT NULL, `bloco` varchar(20) DEFAULT NULL, `minimo_venda` int(10) unsigned DEFAULT '0', `peso_bruto` float unsigned DEFAULT '0', `peso_liquido` float unsigned DEFAULT '0', `embalagem` varchar(50) DEFAULT NULL, `ultima_compra` date DEFAULT NULL, `ultima_venda` date DEFAULT NULL, `ds` char(1) DEFAULT NULL, `da` char(1) DEFAULT NULL, `dv` char(1) DEFAULT NULL, `disponivel` char(1) DEFAULT NULL, `esgotado` char(1) DEFAULT NULL, `previsao_chegada` date DEFAULT NULL, `preco_custo` float unsigned DEFAULT '0', `dolar_compra` float unsigned DEFAULT '0', `custo_frete` float unsigned DEFAULT '0', `custo_funcionario` float unsigned DEFAULT '0', `custo_embalagem` float unsigned DEFAULT '0', `outras_despesas` float unsigned DEFAULT '0', `comissao_vendedor` float unsigned DEFAULT '0', `desconto_permitido` float unsigned DEFAULT '0', `margem_lucro` float DEFAULT '0', `preco_venda` float unsigned DEFAULT '0', `preco_fiscal` float unsigned DEFAULT '0', `tipo_fiscal` char(1) DEFAULT NULL, `ultima_alteracao` datetime DEFAULT NULL, `ultima_alteracao_img` datetime DEFAULT NULL, `cfop_dentro` int(4) unsigned DEFAULT NULL, `cfop_fora` int(4) unsigned DEFAULT NULL, `cfop_st_dentro` int(4) unsigned DEFAULT NULL, `cfop_st_fora` int(4) unsigned DEFAULT NULL, `origem` varchar(20) DEFAULT NULL, `uCom` varchar(6) DEFAULT NULL, `ncm` char(8) DEFAULT NULL, `extipi` char(3) DEFAULT NULL, `ipi` float unsigned DEFAULT '0', `cEnq` char(3) DEFAULT NULL, `CNPJProd` char(18) DEFAULT NULL, `cst` char(3) DEFAULT NULL, `orig` char(1) DEFAULT NULL, `modBC` char(1) DEFAULT NULL, `pICMS` float unsigned DEFAULT '0', `pRedBC` float unsigned DEFAULT '0', `modBCST` char(1) DEFAULT NULL, `pICMSST` float unsigned DEFAULT '0', `pRedBCST` float unsigned DEFAULT '0', `pMVAST` float unsigned DEFAULT '0', PRIMARY KEY (`id`) ) ENGINE=InnoDB AUTO_INCREMENT=5810 DEFAULT CHARSET=latin1; no caso o que eu preciso é o seguinte select * form mi_prdutos where estoque_fiscal >0; select v_comercial from mi_itens_nfiscal as mif where mif.codigo=mi_produtos.id if v_comercial =0 and v_comercial='' and v_comercial= null v_comercial := mi_produtos.preco_fiscal e pra complicar um pouquinho mais tenho que multiplicar esse valor pelo estoque fiscal. mais tem que ser tudo num sql só pois vou usar ele no ReportBuilder no Delphi -
SQL não está retornando como esperado
pergunta respondeu ao Guilherme Freire de Leandro H Mendes em MySQL
tenta retirar o group by do final do select -
presciso fazer uma consulta em duas tabelas porem se o valor não for encontrado na segunda tabela pegar da primeira tabela. eu presciso pegar todos os produtos que tem estoque > 0 e pegar o valor de custo na tabela mi_itens_nota_fiscal. se não encontrar o valor na tabela itens nota fiscal pegar do valor do produto a consulta que eu to ussando é essa : SELECT p.nome, p.estoque_fiscal ,format(mi.V_comercial,2), format((mi.V_comercial * p.estoque_fiscal),2) as valorFiscal FROM mi_itens_nfiscal as mi,mi_produtos as p WHERE mi.codigo=p.id and p.estoque_fiscal>0 group by mi.codigo; porem se ele não encontrar o itens nfiscal ele não pega o produto... aguardo a ajuda de vocês!!! não sei se esse é o lugar certo pois sou novo por ak obrigado
-
[DUVIDA]caregar select em dbedit
pergunta respondeu ao Leandro H Mendes de Leandro H Mendes em Delphi, Kylix
ele faz o select coretamente! o problema é quando eu clico em no proscimo dbedit para editalo ele retorna ao valor do primeiro item da tabela -
Pessoal estou fazendo um sistema de vendas e uso tadoconection to fazendo um select no banco e mostrando em dbedit... porem se eu tento editar ele mostra os dados do primeiro registro do select será que alguém pode me ajudar? with DataModule1.QTcliente do begin Close; SQL.Clear; SQL.Add('SELECT * from cliente where cnpj = '+QuotedStr(Edit1.text)); Open; DBidcliente.Text:= FieldByName('id').Text; DBEdit8.Text:= FieldByName('razao_social').Text; DBEdit9.Text:= FieldByName('nome_fantasia').Text; DBEdit10.Text:= FieldByName('inscricaoest').Text; DBEdit11.Text:= FieldByName('end').Text; DBEdit12.Text:= FieldByName('numero').Text; DBEdit13.Text:= FieldByName('complemento').Text; DBEdit14.Text:= FieldByName('cidade').Text;