Ansible YAML inventory - Groups that are allways members of other groups
According to this best practices post, your file will look like this

file: test

[webservers]
web1
web2
web3

[mysqlservers]
db1
db2
db3

[lamp]
lamp1
lamp2
lamp3

[misc]
host1
host2

[all:children]
misc
webservers
mysqlservers
lamp

[webservers:children]
lamp

[mysqlservers:children]
lamp


You can analyse your file by using ansible-inventory:

ansible-inventory --inventory-file=./test --list


output:

{
    "_meta": {
        "hostvars": {
            "db1": {},
            "db2": {},
            "db3": {},
            "host1": {},
            "host2": {},
            "lamp1": {},
            "lamp2": {},
            "lamp3": {},
            "web1": {},
            "web2": {},
            "web3": {}
        }
    },
    "all": {
        "children": [
            "lamp",
            "misc",
            "mysqlservers",
            "ungrouped",
            "webservers"
        ]
    },
    "lamp": {
        "hosts": [
            "lamp1",
            "lamp2",
            "lamp3"
        ]
    },
    "misc": {
        "hosts": [
            "host1",
            "host2"
        ]
    },
    "mysqlservers": {
        "children": [
            "lamp"
        ],
        "hosts": [
            "db1",
            "db2",
            "db3"
        ]
    },
    "ungrouped": {},
    "webservers": {
        "children": [
            "lamp"
        ],
        "hosts": [
            "web1",
            "web2",
            "web3"
        ]
    }
}