Create view from a single table as one to many

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Create view from a single table as one to many

Joseph L. Casale
I have a table t1 that I am trying to create a view from where the
view will produce many rows for each row in t1. The resulting data
is a set of rows which assign a text string for each bit flag present in
a column in t1 from an enum I reference.

How does one construct such a view?

Thanks,
jlc
_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Create view from a single table as one to many

Clemens Ladisch
Joseph L. Casale wrote:
> I have a table t1 that I am trying to create a view from where the
> view will produce many rows for each row in t1. The resulting data
> is a set of rows which assign a text string for each bit flag present in
> a column in t1 from an enum I reference.
>
> How does one construct such a view?

Join that table with the table that contains the enum values:

  SELECT ... FROM t1 JOIN enums ON t1.flags & enums.bit != 0;


Regards,
Clemens
_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Create view from a single table as one to many

Joseph L. Casale
From: sqlite-users [mailto:[hidden email]] On
Behalf Of Clemens Ladisch
Sent: Saturday, April 8, 2017 7:15 AM
To: [hidden email]
Subject: Re: [sqlite] Create view from a single table as one to many

> Join that table with the table that contains the enum values:
>
>   SELECT ... FROM t1 JOIN enums ON t1.flags & enums.bit != 0;
>
>
> Regards,
> Clemens

Heh,
I can't believe I missed that:) I'll add a table with the enum values.

Thanks Clemens,
jlc

_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Loading...