---
title: Webservice - Data Export
slug: dev-en/webservice-data-export
description: Learn how to retrieve data from CITSmart Database tables for an XML file using a web service. This document provides examples and detailed instructions on querying specific data by passing query conditions and parameters via URL. Explore different possibi
docTags: 
createdAt: 2022-03-07T15:14:54.000Z
---

Through this functionality it is possible, via request to the WebService, to obtain data from the CITSmart Database tables for an XML file.The query conditions for the records that will be returned are passed as parameters via URL as the example below:

```Text
http://localhost/citsmart/services/data/cargos/19  
```

This request returns the records of the positions table where the idcargo, that is, the primary key of the charges table, is equal to 19. The query generated with this request is this:

```mysql
 SELECT IDCARGO, NOMECARGO, DATAINICIO, DATAFIM, IDDESCRICAOCARGO FROM CARGOS WHERE IDCARGO = 19  
```

Below are listed the possibilities and parameters that can be used for data recovery using this feature:

## PK Consultation

It is possible to obtain a record according to a Primary Key field of the reported table.

:::CodeblockTabs
```HTML
 	http://<SERVER ADDRESS>/citsmart/services/data/<TABLE>/<PK VALUE>
```

```MYSQL
	SELECT * FROM <TABLE_NAME> WHERE <PK_FIELD> = <PK_VALUE>
```

```none
	http://localhost/citsmart/services/data/process/19
	   It will search the table PROCESS with the PK Key equal to 19.
```
:::

## Query by Pk and Where

It is possible to obtain a record according to a Primary Key field of the given table and that meets the conditions of a where clause.

:::CodeblockTabs
```HTML
 	http://<SERVER ADDRESS*>/citsmart/services/data/<TABLE>/<PK_VALUE>?cond=<ADDITIONAL_CLAUSES>
```

```MYSQL
	SELECT * FROM <TABLE_NAME> WHERE <PK_FIELD> = <PK_VALUE> AND (<ADDITIONAL_CLAUSES>)
```

```none
        http://localhost/citsmart/services/data/cargos/22?cond=nomecargo like "Diretor"
```
:::

## Where And Ordered Consultation

It is possible to obtain ordered records of a table according to the conditions of a where clause and field for sorted ordering.

:::CodeblockTabs
```HTML
 	http://<SERVER ADDRESS*>/citsmart/services/data/<TABLE>?cond=<WHERE_CRITERIA>&order=<ORDERING FIELD>
```

```MYSQL
	SELECT * FROM <TABLE_NAME> WHERE (<WHERE CRITERIA>) ORDER BY <ORDERING FIELD>
```

```none
	http://localhost/citsmart/services/data/cargos?cond=idcargo<15 and idcargo > 10&order=nomecargo
```
:::

## Query with links to Where and Ordering

It is possible to obtain ordered records of a table, along with the records with which they are linked, according to the conditions of a where clause and field for ordering.

:::CodeblockTabs
```HTML
	http://<SERVER ADDRESS*>/citsmart/services/data/<TABLE>?cond=<WHERE_CRITERIA>&order=<ORDERING FIELD>&links=<s_ou_n>
```

```MYSQL
	SELECT * FROM <TABLE_NAME> WHERE (<WHERE CRITERIA>) ORDER BY <ORDERING FIELD>
```

```none
   	http://localhost/citsmart/services/data/localidade?cond=idlocalidade=1&order=idlocalidade&links=s
```

```none
	cond =Refers to the conditions of the where clause;
	order = Field that will be used in the order by clause;
	links = "S", or "N". When S, the query will also export foreign key bindings. That is, the records of other tables that reference this record. By default, when this option is not entered, the value is N.
```
:::

