Foros Club Delphi

Foros Club Delphi (https://www.clubdelphi.com/foros/index.php)
-   SQL (https://www.clubdelphi.com/foros/forumdisplay.php?f=6)
-   -   ayuda con una consulta (https://www.clubdelphi.com/foros/showthread.php?t=43922)

narcisoplayero 24-05-2007 00:24:50

ayuda con una consulta
 
hola como estas kiero saber como hacer una consult de dos tblas. tengo estos campo en una tabla que se llama maste:
cliente, dpto, familia, fecha, codigo, descripcion, cantidad, precio, impuesto, fraccion, serie, cntoferta, descuentop, impuestootro, costo, suplidor y en la otra tabla master1 tengo estos campos:suplidorid, productid, desmercmae, cntultcpra, itbis, costoprome, fracpra, precventa, framercmae, fecultcpra. quiero saber como puedo hacer una consulta donde me salsan los camps de la primea tabla mas los campo de la segunda juntos los dos, osea realcionado por el campo codigo de la primera tabla,ya que el campo codigo y el campo productid son el mismo.

egostar 24-05-2007 00:33:23

Hola narcisoplayero, puedes completar tu pregunta, así ni como ayudarte.

Salud OS.

Caral 24-05-2007 00:43:28

Hola
Es su primera preguntita, se nos asusto?:rolleyes:
Y ademas le pones ese ojo, amigo, que lo asustas.:D
Saludos Maestro.

ContraVeneno 24-05-2007 00:51:23

No mencionas que base de datos estas utilizando, pero esto funciona en SQL Server:
Código SQL [-]
Select *
from master M
join master1 M1 on M.Codigo=M1.ProductID

Para más información, revisa este enlace.

Bienvenido a los foros

egostar 24-05-2007 00:55:59

Ah ta weno

Yo haría algo así.

Código SQL [-]
SELECT a.cliente, a.dpto, a.familia, a.fecha, a.codigo, a.descripcion, a.cantidad,
 a.precio, a.impuesto, a.fraccion, a.serie, a.cntoferta, a.descuentop, a.impuestootro, 
a.costo, a.suplidor, b.suplidorid, b.desmercmae, b.cntultcpra, b.itbis, b.costoprome, 
b.fracpra, b.precventa, framercmae, fecultcpra FROM master a, master1 b
WHERE a.codigo = b.productid

Salud OS.

egostar 24-05-2007 00:57:15

Cita:

Empezado por ContraVeneno
No mencionas que base de datos estas utilizando, pero esto funciona en SQL Server:
Código SQL [-]Select * from master M join master1 M1 on M.Codigo=M1.ProductID


Para más información, revisa este enlace.

Bienvenido a los foros

Pues asi ni como discutirlo amigo ContraVeneno.:D:D:D

Salud OS.

karlaoax 24-05-2007 16:36:00

Hola narcisoplayero te pongo una seccion con instrucciones para que conozcas acercas del Master/Detail que estoy segura te funcionara mas adelante, espero que tu ingles ande bien :p

Difficulty Level: average Time Required: 10 minutes
Here's How:
1. Start Delphi and select File | New Application...

2. Select Data Access page on the Component palette. Place two TTable components on a form. Place two TDataSource components on a form.

3. Select Data Controls page on the Component palette. Place two TDbGrid components on a form.

4. Set the DatabaseName of the TTable components (Table1 and Table2) to the name of the database to access. Select DBDemos.

5. Set the TableName property to the name of the table in the database. Select customer.db for the master table: Table1.

6. Do the same with the child table. Select orders.db for the Table2.
7. Select the first TDataSource (DataSource1) component and set DataSet property to the name of the table component, that is: Table1.

8. Do the same with the second TDataSource (DataSource2) component and set DataSet property to the name of the table component, that is: Table2.

9. Select the first TDbGrid (DBGrid1) component and set the DataSource property to the name of the data source component, i.e. DataSource1. The same for, that is, TDbGrid2.DataSource:=DataSource2.

10. Set the MasterSource property of the Table2 component to the DataSource1.

11. Set the IndexFieldName property of the Table2 component to the CustNo.

12. Click the ellipsis button next to the MasterFields property of the Table2. This will invoke the Field Link Designer.

13. In the Detail Fields list the select CustNo, in the MasterFields list select CustNo. Click Add. Click Ok.

14. Set the Active property of both table components to True.

15. Browse through the records.


Tips:
The most important thing in master-detail relationship is the link between the tables. For each record in the master table, the form displays all corresponding records in the detail table.
Important detail table properties are: IndexFieldNames, MasterFields and MasterSource. For more info look in Delphi Help files.

Los puntos 12,13 y 14 son los mas importantes, te los marque en azul.

Karla ;)


La franja horaria es GMT +2. Ahora son las 16:22:24.

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Traducción al castellano por el equipo de moderadores del Club Delphi