Hello

I have a question about my database design, and how to query.

I Made an extra table in my database design in where I put the type of
devices(table: type). It has to be possible to add and delete type of devices
in this table.

If you look at my code

(<cfset typenr = "30">
<cfquery name="nr" datasource="testdb">
SELECT MAX(nummer) AS hoogste_nummer FROM device WHERE type = #typenr#
</cfquery>

<cfset nieuwnummer = IncrementValue(nr.hoogste_nummer)>

<cfif
IsDefined("FORM.serial")><cfoutput>#FORM.serial#</cfoutput><cfelse>test</cfif>")

you see:

SELECT MAX(nummer) AS hoogste_nummer FROM device WHERE type = #typenr#

This means that there already has to be a type in the device table of my
database for a specific typenr.
When you want to put in a device for a specific type(you select a type from
the type table) and it's the first record to put in for that type, then the
typenumber cannot be found in the type database field of the device table where
everything has to be stored. It's not there......
I could put in the database a value for each type manually so that for each
type there will be a typenumber in the database already which he know can find
and compares.
But then it would not be possible to dynamically add another type in the type
table....

Hopefully my explanation is understandable....

Does anyone has an Idea how I could fix this?